Skip to content

Internals Router Security SessionCsrfValidator

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

router\security\SessionCsrfValidator

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/router/security/SessionCsrfValidator.php · Snapshot 8411f4287706.

Routing separates definition, HTTP request snapshot, matching, method policy, execution and error responses. Collaborators can be replaced through constructor injection.

Imports and dependencies

use router\interface\ICsrfTokenManager;
use router\interface\ICsrfValidator;
use router\interface\IRequest;

SessionCsrfValidator

Declaration and architectural role

final class SessionCsrfValidator implements ICsrfValidator

Constants, enum cases, traits and properties

Declarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.

Member Declaration Purpose or source contract
Constructor-promoted public function __construct(private readonly ICsrfTokenManager $tokens = new Csrf()) Initialized from the constructor argument; default expression is evaluated when the argument is omitted.

Method index

Method Signature
__construct public function __construct(private readonly ICsrfTokenManager $tokens = new Csrf())
validate public function validate(IRequest $request): bool

__construct

Source line 11

public function __construct(private readonly ICsrfTokenManager $tokens = new Csrf());

Parameters

Parameter Type, modifiers and default Purpose
$tokens private readonly ICsrfTokenManager $tokens = new Csrf() Operation input; the exact use, validation and propagation are shown in the implementation trace.

Concrete no-op/default hook: this method performs no work. Override it where the lifecycle or extension contract calls for behavior.

validate

Source line 13

public function validate(IRequest $request): bool

Parameters

Parameter Type, modifiers and default Purpose
$request IRequest $request Request snapshot consumed by matching, method and security checks.

Return expressions (including local callbacks): $this->tokens->validateToken($request->csrfToken()).

Implementation, validation guards and interaction order
public function validate(IRequest $request): bool
    {
        return $this->tokens->validateToken($request->csrfToken());
    }

Related types

Clone this wiki locally