2022-03-14 19:13:10 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Config;
|
|
|
|
|
2024-04-07 22:17:30 +02:00
|
|
|
use CodeIgniter\Config\Filters as BaseFilters;
|
|
|
|
use CodeIgniter\Filters\Cors;
|
2022-03-14 19:13:10 +01:00
|
|
|
use CodeIgniter\Filters\CSRF;
|
|
|
|
use CodeIgniter\Filters\DebugToolbar;
|
2024-04-07 22:17:30 +02:00
|
|
|
use CodeIgniter\Filters\ForceHTTPS;
|
2022-03-14 19:13:10 +01:00
|
|
|
use CodeIgniter\Filters\Honeypot;
|
2024-04-07 22:17:30 +02:00
|
|
|
use CodeIgniter\Filters\InvalidChars;
|
|
|
|
use CodeIgniter\Filters\PageCache;
|
|
|
|
use CodeIgniter\Filters\PerformanceMetrics;
|
|
|
|
use CodeIgniter\Filters\SecureHeaders;
|
2022-03-14 19:13:10 +01:00
|
|
|
|
2024-04-07 22:17:30 +02:00
|
|
|
class Filters extends BaseFilters
|
2022-03-14 19:13:10 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Configures aliases for Filter classes to
|
|
|
|
* make reading things nicer and simpler.
|
|
|
|
*
|
2024-04-07 22:17:30 +02:00
|
|
|
* @var array<string, class-string|list<class-string>>
|
|
|
|
*
|
|
|
|
* [filter_name => classname]
|
|
|
|
* or [filter_name => [classname1, classname2, ...]]
|
|
|
|
*/
|
|
|
|
public array $aliases = [
|
|
|
|
'csrf' => CSRF::class,
|
|
|
|
'toolbar' => DebugToolbar::class,
|
|
|
|
'honeypot' => Honeypot::class,
|
|
|
|
'invalidchars' => InvalidChars::class,
|
|
|
|
'secureheaders' => SecureHeaders::class,
|
|
|
|
'cors' => Cors::class,
|
|
|
|
'forcehttps' => ForceHTTPS::class,
|
|
|
|
'pagecache' => PageCache::class,
|
|
|
|
'performance' => PerformanceMetrics::class,
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List of special required filters.
|
|
|
|
*
|
|
|
|
* The filters listed here are special. They are applied before and after
|
|
|
|
* other kinds of filters, and always applied even if a route does not exist.
|
|
|
|
*
|
|
|
|
* Filters set by default provide framework functionality. If removed,
|
|
|
|
* those functions will no longer work.
|
|
|
|
*
|
|
|
|
* @see https://codeigniter.com/user_guide/incoming/filters.html#provided-filters
|
|
|
|
*
|
|
|
|
* @var array{before: list<string>, after: list<string>}
|
2022-03-14 19:13:10 +01:00
|
|
|
*/
|
2024-04-07 22:17:30 +02:00
|
|
|
public array $required = [
|
|
|
|
'before' => [
|
|
|
|
'forcehttps', // Force Global Secure Requests
|
|
|
|
'pagecache', // Web Page Caching
|
|
|
|
],
|
|
|
|
'after' => [
|
|
|
|
'pagecache', // Web Page Caching
|
|
|
|
'performance', // Performance Metrics
|
|
|
|
'toolbar', // Debug Toolbar
|
|
|
|
],
|
2022-03-14 19:13:10 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List of filter aliases that are always
|
|
|
|
* applied before and after every request.
|
|
|
|
*
|
2024-04-07 22:17:30 +02:00
|
|
|
* @var array<string, array<string, array<string, string>>>|array<string, list<string>>
|
2022-03-14 19:13:10 +01:00
|
|
|
*/
|
2024-04-07 22:17:30 +02:00
|
|
|
public array $globals = [
|
2022-03-14 19:13:10 +01:00
|
|
|
'before' => [
|
|
|
|
// 'honeypot',
|
|
|
|
// 'csrf',
|
2024-04-07 22:17:30 +02:00
|
|
|
// 'invalidchars',
|
2022-03-14 19:13:10 +01:00
|
|
|
],
|
|
|
|
'after' => [
|
|
|
|
// 'honeypot',
|
2024-04-07 22:17:30 +02:00
|
|
|
// 'secureheaders',
|
2022-03-14 19:13:10 +01:00
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List of filter aliases that works on a
|
|
|
|
* particular HTTP method (GET, POST, etc.).
|
|
|
|
*
|
|
|
|
* Example:
|
2024-04-07 22:17:30 +02:00
|
|
|
* 'POST' => ['foo', 'bar']
|
|
|
|
*
|
|
|
|
* If you use this, you should disable auto-routing because auto-routing
|
|
|
|
* permits any HTTP method to access a controller. Accessing the controller
|
|
|
|
* with a method you don't expect could bypass the filter.
|
2022-03-14 19:13:10 +01:00
|
|
|
*
|
2024-04-07 22:17:30 +02:00
|
|
|
* @var array<string, list<string>>
|
2022-03-14 19:13:10 +01:00
|
|
|
*/
|
2024-04-07 22:17:30 +02:00
|
|
|
public array $methods = [];
|
2022-03-14 19:13:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* List of filter aliases that should run on any
|
|
|
|
* before or after URI patterns.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
|
|
|
|
*
|
2024-04-07 22:17:30 +02:00
|
|
|
* @var array<string, array<string, list<string>>>
|
2022-03-14 19:13:10 +01:00
|
|
|
*/
|
2024-04-07 22:17:30 +02:00
|
|
|
public array $filters = [];
|
2022-03-14 19:13:10 +01:00
|
|
|
}
|