crm-summit/app/Config/Filters.php

118 lines
3.5 KiB
PHP
Raw Normal View History

2024-04-24 13:20:52 +07:00
<?php
namespace Config;
2025-08-15 11:38:41 +07:00
use CodeIgniter\Config\Filters as BaseFilters;
// use CodeIgniter\Filters\Cors;
2024-04-24 13:20:52 +07:00
use CodeIgniter\Filters\CSRF;
use CodeIgniter\Filters\DebugToolbar;
2025-08-15 11:38:41 +07:00
use CodeIgniter\Filters\ForceHTTPS;
2024-04-24 13:20:52 +07:00
use CodeIgniter\Filters\Honeypot;
use CodeIgniter\Filters\InvalidChars;
2025-08-15 11:38:41 +07:00
use CodeIgniter\Filters\PageCache;
use CodeIgniter\Filters\PerformanceMetrics;
2024-04-24 13:20:52 +07:00
use CodeIgniter\Filters\SecureHeaders;
2025-08-15 11:38:41 +07:00
class Filters extends BaseFilters
2024-04-24 13:20:52 +07:00
{
/**
* Configures aliases for Filter classes to
* make reading things nicer and simpler.
*
2025-08-15 11:38:41 +07:00
* @var array<string, class-string|list<class-string>>
*
* [filter_name => classname]
* or [filter_name => [classname1, classname2, ...]]
2024-04-24 13:20:52 +07:00
*/
2025-08-15 11:38:41 +07:00
public array $aliases = [
2024-04-24 13:20:52 +07:00
'csrf' => CSRF::class,
'toolbar' => DebugToolbar::class,
'honeypot' => Honeypot::class,
'invalidchars' => InvalidChars::class,
'secureheaders' => SecureHeaders::class,
2025-08-15 11:38:41 +07:00
'forcehttps' => ForceHTTPS::class,
'pagecache' => PageCache::class,
2025-10-21 21:59:15 +07:00
'performance' => PerformanceMetrics::class,
2025-08-15 11:38:41 +07:00
'cors' => \App\Filters\Cors::class,
2025-10-21 21:59:15 +07:00
'auth' => \App\Filters\Auth::class,
2024-04-24 13:20:52 +07:00
];
/**
2025-08-15 11:38:41 +07:00
* 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.
2024-04-24 13:20:52 +07:00
*
2025-08-15 11:38:41 +07:00
* @see https://codeigniter.com/user_guide/incoming/filters.html#provided-filters
*
* @var array{before: list<string>, after: list<string>}
2024-04-24 13:20:52 +07:00
*/
2025-08-15 11:38:41 +07:00
public array $required = [
2024-04-24 13:20:52 +07:00
'before' => [
// 'honeypot',
// 'csrf',
// 'invalidchars',
],
'after' => [
2025-08-15 11:38:41 +07:00
'pagecache', // Web Page Caching
'performance', // Performance Metrics
'toolbar', // Debug Toolbar
],
];
/**
* List of filter aliases that are always
* applied before and after every request.
*
* @var array{
* before: array<string, array{except: list<string>|string}>|list<string>,
* after: array<string, array{except: list<string>|string}>|list<string>
* }
*/
public array $globals = [
'before' => [
// 'cors',
'auth' => [ 'except' => [
'auth/*', 'lqms/*', 'key/*', 'api/*', 'certificates/number/*'
]]
2025-08-15 11:38:41 +07:00
// 'honeypot',
// 'csrf',
// 'invalidchars',
],
'after' => [
'toolbar',
2024-04-24 13:20:52 +07:00
// 'honeypot',
// 'secureheaders',
],
];
/**
* List of filter aliases that works on a
* particular HTTP method (GET, POST, etc.).
*
* Example:
2025-08-15 11:38:41 +07:00
* 'POST' => ['foo', 'bar']
2024-04-24 13:20:52 +07:00
*
* If you use this, you should disable auto-routing because auto-routing
* permits any HTTP method to access a controller. Accessing the controller
2025-08-15 11:38:41 +07:00
* with a method you don't expect could bypass the filter.
2024-04-24 13:20:52 +07:00
*
2025-08-15 11:38:41 +07:00
* @var array<string, list<string>>
2024-04-24 13:20:52 +07:00
*/
2025-08-15 11:38:41 +07:00
public array $methods = [];
2024-04-24 13:20:52 +07:00
/**
* List of filter aliases that should run on any
* before or after URI patterns.
*
* Example:
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
*
2025-08-15 11:38:41 +07:00
* @var array<string, array<string, list<string>>>
2024-04-24 13:20:52 +07:00
*/
2025-08-15 11:38:41 +07:00
public array $filters = [];
2024-04-24 13:20:52 +07:00
}