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

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. $settings = [
  3. 'database' => 'php-crud-api',
  4. 'username' => 'php-crud-api',
  5. 'password' => 'php-crud-api',
  6. 'controllers' => 'records,columns,cache,openapi',
  7. 'middlewares' => 'cors,jwtAuth,basicAuth,authorization,validation,sanitation,multiTenancy,customization',
  8. 'jwtAuth.time' => '1538207605',
  9. 'jwtAuth.secret' => 'axpIrCGNGqxzx2R9dtXLIPUSqPo778uhb8CA0F4Hx',
  10. 'basicAuth.passwordFile' => __DIR__ . DIRECTORY_SEPARATOR . '.htpasswd',
  11. 'authorization.tableHandler' => function ($operation, $tableName) {
  12. return !($tableName == 'invisibles' && !isset($_SESSION['claims']['name']) && empty($_SESSION['username']));
  13. },
  14. 'authorization.columnHandler' => function ($operation, $tableName, $columnName) {
  15. return !($columnName == 'invisible');
  16. },
  17. 'authorization.recordHandler' => function ($operation, $tableName) {
  18. return ($tableName == 'comments') ? 'filter=message,neq,invisible' : '';
  19. },
  20. 'sanitation.handler' => function ($operation, $tableName, $column, $value) {
  21. return is_string($value) ? strip_tags($value) : $value;
  22. },
  23. 'validation.handler' => function ($operation, $tableName, $column, $value, $context) {
  24. return ($column['name'] == 'post_id' && !is_numeric($value)) ? 'must be numeric' : true;
  25. },
  26. 'multiTenancy.handler' => function ($operation, $tableName) {
  27. return ($tableName == 'kunsthåndværk') ? ['user_id' => 1] : [];
  28. },
  29. 'customization.beforeHandler' => function ($operation, $tableName, $request, $environment) {
  30. $environment->start = 0.003/*microtime(true)*/;
  31. },
  32. 'customization.afterHandler' => function ($operation, $tableName, $response, $environment) {
  33. if ($tableName == 'kunsthåndværk' && $operation == 'increment') {
  34. $response->addHeader('X-Time-Taken', 0.006/*microtime(true)*/ - $environment->start);
  35. }
  36. },
  37. 'debug' => true,
  38. ];