2020-08-04 11:25:22 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2020-08-04 11:25:22 +00:00
|
|
|
|
namespace Config;
|
2020-05-27 18:46:16 +02:00
|
|
|
|
|
2023-08-21 16:13:03 +00:00
|
|
|
|
use App\Filters\AllowCorsFilter;
|
2020-05-27 18:46:16 +02:00
|
|
|
|
use CodeIgniter\Config\BaseConfig;
|
2021-04-02 17:20:02 +00:00
|
|
|
|
use CodeIgniter\Filters\CSRF;
|
|
|
|
|
use CodeIgniter\Filters\DebugToolbar;
|
2024-04-26 09:26:22 +00:00
|
|
|
|
use CodeIgniter\Filters\ForceHTTPS;
|
2021-04-02 17:20:02 +00:00
|
|
|
|
use CodeIgniter\Filters\Honeypot;
|
2022-01-04 15:40:27 +00:00
|
|
|
|
use CodeIgniter\Filters\InvalidChars;
|
2024-04-26 09:26:22 +00:00
|
|
|
|
use CodeIgniter\Filters\PageCache;
|
|
|
|
|
use CodeIgniter\Filters\PerformanceMetrics;
|
2022-01-04 15:40:27 +00:00
|
|
|
|
use CodeIgniter\Filters\SecureHeaders;
|
2021-08-23 11:05:16 +00:00
|
|
|
|
use Modules\Auth\Filters\PermissionFilter;
|
2020-05-27 18:46:16 +02:00
|
|
|
|
|
|
|
|
|
class Filters extends BaseConfig
|
|
|
|
|
{
|
2021-04-02 17:20:02 +00:00
|
|
|
|
/**
|
2021-05-19 16:35:13 +00:00
|
|
|
|
* Configures aliases for Filter classes to make reading things nicer and simpler.
|
2021-04-02 17:20:02 +00:00
|
|
|
|
*
|
2024-04-26 09:26:22 +00:00
|
|
|
|
* @var array<string, class-string|list<class-string>>
|
|
|
|
|
*
|
|
|
|
|
* [filter_name => classname]
|
|
|
|
|
* or [filter_name => [classname1, classname2, ...]]
|
2021-04-02 17:20:02 +00:00
|
|
|
|
*/
|
2021-05-18 17:16:36 +00:00
|
|
|
|
public array $aliases = [
|
2023-07-06 14:05:36 +00:00
|
|
|
|
'csrf' => CSRF::class,
|
|
|
|
|
'toolbar' => DebugToolbar::class,
|
|
|
|
|
'honeypot' => Honeypot::class,
|
|
|
|
|
'invalidchars' => InvalidChars::class,
|
|
|
|
|
'secureheaders' => SecureHeaders::class,
|
2023-08-21 16:13:03 +00:00
|
|
|
|
'allow-cors' => AllowCorsFilter::class,
|
2024-04-26 09:26:22 +00:00
|
|
|
|
'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>}
|
|
|
|
|
*/
|
|
|
|
|
public array $required = [
|
|
|
|
|
'before' => [
|
|
|
|
|
'forcehttps', // Force Global Secure Requests
|
|
|
|
|
'pagecache', // Web Page Caching
|
|
|
|
|
],
|
|
|
|
|
'after' => [
|
|
|
|
|
'pagecache', // Web Page Caching
|
|
|
|
|
'performance', // Performance Metrics
|
|
|
|
|
'toolbar', // Debug Toolbar
|
|
|
|
|
],
|
2020-06-10 15:00:12 +00:00
|
|
|
|
];
|
2020-05-27 18:46:16 +02:00
|
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
|
/**
|
2021-05-19 16:35:13 +00:00
|
|
|
|
* List of filter aliases that are always applied before and after every request.
|
2021-04-02 17:20:02 +00:00
|
|
|
|
*
|
2024-04-26 09:26:22 +00:00
|
|
|
|
* @var array<string, array<string, array<string, string|array<string>>>>>|array<string, list<string>>
|
2021-04-02 17:20:02 +00:00
|
|
|
|
*/
|
2021-05-18 17:16:36 +00:00
|
|
|
|
public array $globals = [
|
2020-06-10 15:00:12 +00:00
|
|
|
|
'before' => [
|
2021-04-02 17:20:02 +00:00
|
|
|
|
// 'honeypot',
|
2022-03-04 14:33:48 +00:00
|
|
|
|
'csrf' => [
|
2024-10-24 12:48:16 +00:00
|
|
|
|
'except' => [
|
|
|
|
|
'@[a-zA-Z0-9\_]{1,32}/inbox',
|
|
|
|
|
'api/rest/v1/episodes',
|
|
|
|
|
'api/rest/v1/episodes/[0-9]+/publish',
|
|
|
|
|
],
|
2022-03-04 14:33:48 +00:00
|
|
|
|
],
|
2022-01-04 15:40:27 +00:00
|
|
|
|
// 'invalidchars',
|
2020-06-10 15:00:12 +00:00
|
|
|
|
],
|
|
|
|
|
'after' => [
|
2021-04-02 17:20:02 +00:00
|
|
|
|
// 'honeypot',
|
2022-01-04 15:40:27 +00:00
|
|
|
|
// 'secureheaders',
|
2020-06-10 15:00:12 +00:00
|
|
|
|
],
|
|
|
|
|
];
|
2020-05-27 18:46:16 +02:00
|
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
|
/**
|
2021-05-19 16:35:13 +00:00
|
|
|
|
* List of filter aliases that works on a particular HTTP method (GET, POST, etc.).
|
2021-04-02 17:20:02 +00:00
|
|
|
|
*
|
2024-04-26 09:26:22 +00:00
|
|
|
|
* Example: 'POST' => ['foo', 'bar']
|
2022-06-13 16:30:34 +00:00
|
|
|
|
*
|
|
|
|
|
* 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.
|
2021-04-02 17:20:02 +00:00
|
|
|
|
*
|
2024-04-26 09:26:22 +00:00
|
|
|
|
* @var array<string, list<string>>
|
2021-04-02 17:20:02 +00:00
|
|
|
|
*/
|
2021-05-18 17:16:36 +00:00
|
|
|
|
public array $methods = [];
|
2020-05-27 18:46:16 +02:00
|
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
|
/**
|
2021-05-19 16:35:13 +00:00
|
|
|
|
* List of filter aliases that should run on any before or after URI patterns.
|
2021-04-02 17:20:02 +00:00
|
|
|
|
*
|
2021-05-19 16:35:13 +00:00
|
|
|
|
* Example: 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
|
2021-04-02 17:20:02 +00:00
|
|
|
|
*
|
2024-04-26 09:26:22 +00:00
|
|
|
|
* @var array<string, array<string, list<string>>>
|
2021-04-02 17:20:02 +00:00
|
|
|
|
*/
|
2021-05-18 17:16:36 +00:00
|
|
|
|
public array $filters = [];
|
2020-07-10 12:20:25 +00:00
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
|
|
$this->filters = [
|
2022-10-15 11:22:08 +00:00
|
|
|
|
'session' => [
|
2023-11-15 16:17:43 +00:00
|
|
|
|
'before' => [config('Admin')->gateway . '*', config('Analytics')->gateway . '*'],
|
2021-05-19 16:35:13 +00:00
|
|
|
|
],
|
2022-09-28 15:02:09 +00:00
|
|
|
|
'podcast-unlock' => [
|
|
|
|
|
'before' => ['*@*/episodes/*'],
|
|
|
|
|
],
|
2020-07-10 12:20:25 +00:00
|
|
|
|
];
|
2023-07-06 13:50:10 +00:00
|
|
|
|
|
|
|
|
|
$this->aliases['permission'] = PermissionFilter::class;
|
2020-07-10 12:20:25 +00:00
|
|
|
|
}
|
2020-05-27 18:46:16 +02:00
|
|
|
|
}
|