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.7KB

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