class CsrfToken extends AuthMiddleware implements MiddlewareInterface

Verify Csrf token middleware

Properties

protected array $authProviders Auth provider from AuthMiddleware
protected array $options Options from AuthMiddleware

Methods

__construct(array $authProviders, array $options = [])

Constructor

void
setAuthProviders(array $authProviders)

Set Auth providers

ResponseInterface
process(ServerRequestInterface $request, RequestHandlerInterface $handler)

Process middleware

getAuthProvider($name)

Get auth provider

string
handleError(ServerRequestInterface $request, RequestHandlerInterface $handler)

Show auth error

mixed
getOption(string $key, mixed|null $default = null)

Get option value

ServerRequestInterface
generateToken(ServerRequestInterface $request)

Vreate new token if middleware param recreate_token is set to true

string|null
getToken(ServerRequestInterface $request)

Get csrf token from request

Details

in AuthMiddleware at line 48
__construct(array $authProviders, array $options = [])

Constructor

Parameters

array $authProviders
array $options

in AuthMiddleware at line 60
void setAuthProviders(array $authProviders)

Set Auth providers

Parameters

array $authProviders

Return Value

void

at line 32
ResponseInterface process(ServerRequestInterface $request, RequestHandlerInterface $handler)

Process middleware

Parameters

ServerRequestInterface $request
RequestHandlerInterface $handler

Return Value

ResponseInterface

in AuthMiddleware at line 99
AuthProviderInterface|null getAuthProvider($name)

Get auth provider

Parameters

$name

Return Value

AuthProviderInterface|null

in AuthMiddleware at line 112
protected string handleError(ServerRequestInterface $request, RequestHandlerInterface $handler)

Show auth error

Parameters

ServerRequestInterface $request
RequestHandlerInterface $handler

Return Value

string

Exceptions

HttpNotFoundException

in AuthMiddleware at line 140
protected mixed getOption(string $key, mixed|null $default = null)

Get option value

Parameters

string $key
mixed|null $default

Return Value

mixed

at line 54
protected ServerRequestInterface generateToken(ServerRequestInterface $request)

Vreate new token if middleware param recreate_token is set to true

Parameters

ServerRequestInterface $request

Return Value

ServerRequestInterface

at line 70
string|null getToken(ServerRequestInterface $request)

Get csrf token from request

Parameters

ServerRequestInterface $request

Return Value

string|null