class CSRFVerifier

Properties

static CSRFVerifier|null $instance

Methods

static CSRFVerifier
get()

Get the singleton instance of the CSRFVerifier.

__construct()

Constructor for the CSRFVerifier class.

string
getToken()

Get the CSRF token from the session.

void
addException(string $pattern)

Add a URI pattern to the list of CSRF exceptions.

bool
isException(string $uri)

Check if a given URI matches any of the CSRF exceptions.

bool
validateRequest(ServerRequest $request)

Validate the CSRF token in the incoming request.

string
getTokenInput()

Generate an HTML input element containing the CSRF token.

Details

at line 25
static CSRFVerifier get()

Get the singleton instance of the CSRFVerifier.

Return Value

CSRFVerifier

The singleton instance of the CSRFVerifier.

at line 36
__construct()

Constructor for the CSRFVerifier class.

Starts the session and initializes the CSRF token if not already set.

at line 51
string getToken()

Get the CSRF token from the session.

Return Value

string

The CSRF token.

at line 60
void addException(string $pattern)

Add a URI pattern to the list of CSRF exceptions.

Parameters

string $pattern

The URI pattern to add as an exception.

Return Value

void

at line 70
bool isException(string $uri)

Check if a given URI matches any of the CSRF exceptions.

Parameters

string $uri

The URI to check.

Return Value

bool

True if the URI matches an exception, false otherwise.

at line 86
bool validateRequest(ServerRequest $request)

Validate the CSRF token in the incoming request.

Parameters

ServerRequest $request

The incoming server request.

Return Value

bool

True if the request is valid, false otherwise.

at line 107
string getTokenInput()

Generate an HTML input element containing the CSRF token.

Return Value

string

The HTML input element with the CSRF token.