2020-08-04 11:25:22 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Config;
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
use ActivityPub\Filters\ActivityPubFilter;
|
2021-05-19 16:35:13 +00:00
|
|
|
use App\Filters\PermissionFilter;
|
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;
|
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,
|
2021-05-06 14:00:48 +00:00
|
|
|
'login' => LoginFilter::class,
|
|
|
|
'role' => RoleFilter::class,
|
|
|
|
'permission' => PermissionFilter::class,
|
|
|
|
'activity-pub' => ActivityPubFilter::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',
|
|
|
|
],
|
|
|
|
'after' => [
|
|
|
|
'toolbar',
|
2021-04-02 17:20:02 +00:00
|
|
|
// 'honeypot',
|
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' => [
|
|
|
|
'before' => [config('App')->adminGateway . '*'],
|
|
|
|
],
|
2020-07-10 12:20:25 +00:00
|
|
|
];
|
|
|
|
}
|
2020-05-27 18:46:16 +02:00
|
|
|
}
|