<?php
namespace Config;

use CodeIgniter\Config\BaseConfig;

class Filters extends BaseConfig
{
    /**
     * Configures aliases for Filter classes.
     */
    public array $aliases = [
        'csrf'       => \CodeIgniter\Filters\CSRF::class,
        'toolbar'    => \CodeIgniter\Filters\DebugToolbar::class,
        'honeypot'   => \CodeIgniter\Filters\Honeypot::class,
        'invalidchars'=> \CodeIgniter\Filters\InvalidChars::class,
        'secureheaders'=> \CodeIgniter\Filters\SecureHeaders::class,
        // Application filters
        'auth'       => \App\Filters\AuthFilter::class,
        'rbac'       => \App\Filters\RbacFilter::class,
        'throttle'   => \App\Filters\LoginThrottleFilter::class,
        'jwt'        => \App\Filters\JwtFilter::class,
    ];

    /**
     * List of filter aliases to always apply, regardless of route.
     */
    public array $globals = [
        'before' => [
            'honeypot',
            'csrf' => ['except' => [
                'api/*',           // API uses JWT not CSRF
                'request',         // Public maintenance portal
                'track/*',         // Public tracking
            ]],
        ],
        'after' => [
            'toolbar',
            'secureheaders',
        ],
    ];

    /**
     * List of filter aliases that work on a particular HTTP method.
     */
    public array $methods = [];

    /**
     * List of filter aliases that should run on any before or after URI patterns.
     * These are applied when the filter alias matches the route.
     */
    public array $filters = [];
}
