api de gestion de ticket, basé sur php-crud-api. Le but est de décorrélé les outils de gestion des données, afin
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

base.php 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. $settings = [
  3. 'database' => 'incorrect_database',
  4. 'username' => 'incorrect_username',
  5. 'password' => 'incorrect_password',
  6. 'controllers' => 'records,columns,cache,openapi,geojson',
  7. 'middlewares' => 'sslRedirect,xml,cors,reconnect,dbAuth,jwtAuth,basicAuth,authorization,sanitation,validation,ipAddress,multiTenancy,pageLimits,joinLimits,customization',
  8. 'dbAuth.mode' => 'optional',
  9. 'dbAuth.returnedColumns' => 'id,username,password',
  10. 'dbAuth.registerUser' => '1',
  11. 'dbAuth.passwordLength' => '4',
  12. 'jwtAuth.mode' => 'optional',
  13. 'jwtAuth.time' => '1538207605',
  14. 'jwtAuth.secrets' => 'axpIrCGNGqxzx2R9dtXLIPUSqPo778uhb8CA0F4Hx',
  15. 'basicAuth.mode' => 'optional',
  16. 'basicAuth.passwordFile' => __DIR__ . DIRECTORY_SEPARATOR . '.htpasswd',
  17. 'reconnect.databaseHandler' => function () {
  18. return 'php-crud-api';
  19. },
  20. 'reconnect.usernameHandler' => function () {
  21. return 'php-crud-api';
  22. },
  23. 'reconnect.passwordHandler' => function () {
  24. return 'php-crud-api';
  25. },
  26. 'authorization.tableHandler' => function ($operation, $tableName) {
  27. return !($tableName == 'invisibles' && !isset($_SESSION['claims']['name']) && empty($_SESSION['username']) && empty($_SESSION['user']));
  28. },
  29. 'authorization.columnHandler' => function ($operation, $tableName, $columnName) {
  30. return !($columnName == 'invisible');
  31. },
  32. 'authorization.recordHandler' => function ($operation, $tableName) {
  33. return ($tableName == 'comments') ? 'filter=message,neq,invisible' : '';
  34. },
  35. 'ipAddress.tables' => 'barcodes',
  36. 'ipAddress.columns' => 'ip_address',
  37. 'sanitation.handler' => function ($operation, $tableName, $column, $value) {
  38. return is_string($value) ? strip_tags($value) : $value;
  39. },
  40. 'sanitation.tables' => 'forgiving',
  41. 'validation.handler' => function ($operation, $tableName, $column, $value, $context) {
  42. return ($column['name'] == 'post_id' && !is_numeric($value)) ? 'must be numeric' : true;
  43. },
  44. 'multiTenancy.handler' => function ($operation, $tableName) {
  45. return ($tableName == 'kunsthåndværk') ? ['user_id' => 1] : [];
  46. },
  47. 'pageLimits.pages' => 5,
  48. 'pageLimits.records' => 10,
  49. 'joinLimits.depth' => 2,
  50. 'joinLimits.tables' => 4,
  51. 'joinLimits.records' => 10,
  52. 'customization.beforeHandler' => function ($operation, $tableName, $request, $environment) {
  53. $environment->start = 0.003/*microtime(true)*/;
  54. },
  55. 'customization.afterHandler' => function ($operation, $tableName, $response, $environment) {
  56. if ($tableName == 'kunsthåndværk' && $operation == 'increment') {
  57. return $response->withHeader('X-Time-Taken', 0.006/*microtime(true)*/ - $environment->start);
  58. }
  59. },
  60. 'debug' => false,
  61. ];