Filters.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. namespace Config;
  3. use CodeIgniter\Config\Filters as BaseFilters;
  4. use CodeIgniter\Filters\Cors;
  5. use CodeIgniter\Filters\CSRF;
  6. use CodeIgniter\Filters\DebugToolbar;
  7. use CodeIgniter\Filters\ForceHTTPS;
  8. use CodeIgniter\Filters\Honeypot;
  9. use CodeIgniter\Filters\InvalidChars;
  10. use CodeIgniter\Filters\PageCache;
  11. use CodeIgniter\Filters\PerformanceMetrics;
  12. use CodeIgniter\Filters\SecureHeaders;
  13. class Filters extends BaseFilters
  14. {
  15. /**
  16. * Configures aliases for Filter classes to
  17. * make reading things nicer and simpler.
  18. *
  19. * @var array<string, class-string|list<class-string>>
  20. *
  21. * [filter_name => classname]
  22. * or [filter_name => [classname1, classname2, ...]]
  23. */
  24. public array $aliases = [
  25. 'csrf' => CSRF::class,
  26. 'toolbar' => DebugToolbar::class,
  27. 'honeypot' => Honeypot::class,
  28. 'invalidchars' => InvalidChars::class,
  29. 'secureheaders' => SecureHeaders::class,
  30. 'cors' => Cors::class,
  31. 'forcehttps' => ForceHTTPS::class,
  32. 'pagecache' => PageCache::class,
  33. 'performance' => PerformanceMetrics::class,
  34. 'auth' => \App\Filters\AuthFilter::class,
  35. // 'WhiteList' => \App\Filters\WhiteList::class,
  36. ];
  37. /**
  38. * List of special required filters.
  39. *
  40. * The filters listed here are special. They are applied before and after
  41. * other kinds of filters, and always applied even if a route does not exist.
  42. *
  43. * Filters set by default provide framework functionality. If removed,
  44. * those functions will no longer work.
  45. *
  46. * @see https://codeigniter.com/user_guide/incoming/filters.html#provided-filters
  47. *
  48. * @var array{before: list<string>, after: list<string>}
  49. */
  50. public array $required = [
  51. 'before' => [
  52. 'forcehttps', // Force Global Secure Requests
  53. 'pagecache', // Web Page Caching
  54. ],
  55. 'after' => [
  56. 'pagecache', // Web Page Caching
  57. 'performance', // Performance Metrics
  58. 'toolbar', // Debug Toolbar
  59. ],
  60. ];
  61. /**
  62. * List of filter aliases that are always
  63. * applied before and after every request.
  64. *
  65. * @var array<string, array<string, array<string, string>>>|array<string, list<string>>
  66. */
  67. public array $globals = [
  68. 'before' => [
  69. // 'honeypot',
  70. // 'csrf',
  71. // 'invalidchars',
  72. //'WhiteList'
  73. ],
  74. 'after' => [
  75. // 'honeypot',
  76. // 'secureheaders',
  77. ],
  78. ];
  79. /**
  80. * List of filter aliases that works on a
  81. * particular HTTP method (GET, POST, etc.).
  82. *
  83. * Example:
  84. * 'POST' => ['foo', 'bar']
  85. *
  86. * If you use this, you should disable auto-routing because auto-routing
  87. * permits any HTTP method to access a controller. Accessing the controller
  88. * with a method you don't expect could bypass the filter.
  89. *
  90. * @var array<string, list<string>>
  91. */
  92. public array $methods = [];
  93. /**
  94. * List of filter aliases that should run on any
  95. * before or after URI patterns.
  96. *
  97. * Example:
  98. * 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
  99. *
  100. * @var array<string, array<string, list<string>>>
  101. */
  102. public array $filters = [];
  103. }