class VerifyCsrfToken

Properties

protected Application $app

The application instance.

protected Encrypter $encrypter

The encrypter implementation.

protected array $except

The URIs that should be excluded from CSRF verification.

Methods

void
__construct(Application $app, Encrypter $encrypter)

Create a new middleware instance.

mixed
handle(Request $request, Closure $next)

Handle an incoming request.

bool
isReading(Request $request)

Determine if the HTTP request uses a ‘read’ verb.

bool
runningUnitTests()

Determine if the application is running unit tests.

bool
inExceptArray(Request $request)

Determine if the request has a URI that should pass through CSRF verification.

bool
tokensMatch(Request $request)

Determine if the session and input CSRF tokens match.

string
getTokenFromRequest(Request $request)

Get the CSRF token from the request.

Response
addCookieToResponse(Request $request, Response $response)

Add the CSRF token to the response cookies.

Details

at line 42
void __construct(Application $app, Encrypter $encrypter)

Create a new middleware instance.

Parameters

Application $app
Encrypter $encrypter

Return Value

void

at line 57
mixed handle(Request $request, Closure $next)

Handle an incoming request.

Parameters

Request $request
Closure $next

Return Value

mixed

Exceptions

TokenMismatchException

at line 77
protected bool isReading(Request $request)

Determine if the HTTP request uses a ‘read’ verb.

Parameters

Request $request

Return Value

bool

at line 87
protected bool runningUnitTests()

Determine if the application is running unit tests.

Return Value

bool

at line 98
protected bool inExceptArray(Request $request)

Determine if the request has a URI that should pass through CSRF verification.

Parameters

Request $request

Return Value

bool

at line 119
protected bool tokensMatch(Request $request)

Determine if the session and input CSRF tokens match.

Parameters

Request $request

Return Value

bool

at line 134
protected string getTokenFromRequest(Request $request)

Get the CSRF token from the request.

Parameters

Request $request

Return Value

string

at line 152
protected Response addCookieToResponse(Request $request, Response $response)

Add the CSRF token to the response cookies.

Parameters

Request $request
Response $response

Return Value

Response