CsrfTokenAware
- Full name:
\Codefy\Framework\Http\Middleware\Csrf\Traits\CsrfTokenAware
Properties
salt
isNew
Methods
generateToken
prepareToken
Parameters:
| Parameter | Type | Description |
|---|---|---|
$request | \Psr\Http\Message\ServerRequestInterface |
Throws:
getTokenFromCookie
Get the token from the request cookie if it's present.
Decrypt the cookie token value using the app crypto key.
Return null if the cookie is missing or if the decryption fails.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$cookies | array |
Throws:
createCookie
Create CSRF cookie to store the encrypted token value.
private createCookie(\Psr\Http\Message\ResponseInterface $response, string $token): \Psr\Http\Message\ResponseInterface
Encrypt the value for better security (in case of XSS attack).
Parameters:
| Parameter | Type | Description |
|---|---|---|
$response | \Psr\Http\Message\ResponseInterface | |
$token | string |
Throws: