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
|
|
|
|
|
|
|
use CodeIgniter\Config\BaseConfig;
|
2021-04-02 17:20:02 +00:00
|
|
|
use CodeIgniter\Filters\CSRF;
|
|
|
|
use CodeIgniter\Filters\DebugToolbar;
|
|
|
|
use CodeIgniter\Filters\Honeypot;
|
2022-01-04 15:40:27 +00:00
|
|
|
use CodeIgniter\Filters\InvalidChars;
|
|
|
|
use CodeIgniter\Filters\SecureHeaders;
|
2021-08-23 11:05:16 +00:00
|
|
|
use Modules\Auth\Filters\PermissionFilter;
|
2021-08-27 10:58:22 +00:00
|
|
|
use Modules\Fediverse\Filters\FediverseFilter;
|
2021-05-19 16:35:13 +00:00
|
|
|
use Myth\Auth\Filters\LoginFilter;
|
|
|
|
use Myth\Auth\Filters\RoleFilter;
|
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
|
|
|
*
|
2021-05-14 17:59:35 +00:00
|
|
|
* @var array<string, string>
|
2021-04-02 17:20:02 +00:00
|
|
|
*/
|
2021-05-18 17:16:36 +00:00
|
|
|
public array $aliases = [
|
2021-04-02 17:20:02 +00:00
|
|
|
'csrf' => CSRF::class,
|
|
|
|
'toolbar' => DebugToolbar::class,
|
|
|
|
'honeypot' => Honeypot::class,
|
2022-01-04 15:40:27 +00:00
|
|
|
'invalidchars' => InvalidChars::class,
|
|
|
|
'secureheaders' => SecureHeaders::class,
|
2021-05-06 14:00:48 +00:00
|
|
|
'login' => LoginFilter::class,
|
|
|
|
'role' => RoleFilter::class,
|
|
|
|
'permission' => PermissionFilter::class,
|
2021-08-27 10:58:22 +00:00
|
|
|
'activity-pub' => FediverseFilter::class,
|
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
|
|
|
*
|
2021-05-14 17:59:35 +00:00
|
|
|
* @var array<string, 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',
|
2020-06-10 15:00:12 +00:00
|
|
|
// 'csrf',
|
2022-01-04 15:40:27 +00:00
|
|
|
// 'invalidchars',
|
2020-06-10 15:00:12 +00:00
|
|
|
],
|
|
|
|
'after' => [
|
|
|
|
'toolbar',
|
2021-04-02 17:20:02 +00:00
|
|
|
// 'honeypot',
|
2022-01-04 15:40:27 +00:00
|
|
|
// 'honeypot',
|
|
|
|
// '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
|
|
|
*
|
2021-05-19 16:35:13 +00:00
|
|
|
* Example: 'post' => ['csrf', 'throttle']
|
2021-04-02 17:20:02 +00:00
|
|
|
*
|
2021-05-14 17:59:35 +00:00
|
|
|
* @var array<string, 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
|
|
|
*
|
2021-05-14 17:59:35 +00:00
|
|
|
* @var array<string, array<string, 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 = [
|
2021-05-19 16:35:13 +00:00
|
|
|
'login' => [
|
2021-08-23 11:05:16 +00:00
|
|
|
'before' => [config('Admin') ->gateway . '*', config('Analytics') ->gateway . '*'],
|
2021-05-19 16:35:13 +00:00
|
|
|
],
|
2020-07-10 12:20:25 +00:00
|
|
|
];
|
|
|
|
}
|
2020-05-27 18:46:16 +02:00
|
|
|
}
|