AntiCSRF class
Framework\HTTP\AntiCSRF
Class AntiCSRF.
Defined in libraries/http/src/AntiCSRF.php
Properties #
- $tokenName
- -
- $request
- -
- $verified
- -
- $enabled
- -
- $tokenBytesLength
- -
- $generateTokenFunction
- -
- $generateTokenFunctions
- -
$tokenName
$request
$verified
$enabled
$tokenBytesLength
$generateTokenFunction
$generateTokenFunctions
Methods #
- __construct()
- AntiCSRF constructor.
- disable()
- Disables the Anti CSRF verification.
- enable()
- Enables the Anti CSRF verification.
- generateToken()
- -
- getGenerateTokenFunction()
- -
- getToken()
- Gets the anti-csrf token from the session.
- getTokenBytesLength()
- -
- getTokenName()
- Gets the anti-csrf token name.
- getUserToken()
- Gets the user token from the request input form.
- input()
- Gets the HTML form hidden input if the verification is enabled.
- isEnabled()
- Tells if the verification is enabled.
- isSafeMethod()
- Safe HTTP Request methods are: GET, HEAD and OPTIONS.
- setGenerateTokenFunction()
- -
- setToken()
- Sets the anti-csrf token into the session.
- setTokenBytesLength()
- -
- setTokenName()
- Sets the anti-csrf token name.
- validate()
- Validates if a user token is equals the session token.
- verify()
- Verifies the request input token, if the verification is enabled. The verification always succeed on HTTP GET, HEAD and OPTIONS methods. If verification is successful with other HTTP methods, a new token is generated.
- isVerified()
- -
- setVerified()
- -
__construct()
AntiCSRF constructor.
- \Framework\HTTP\Request $request
- ?int $tokenBytesLength
- ?string $generateTokenFunction
disable()
Disables the Anti CSRF verification.
enable()
Enables the Anti CSRF verification.
generateToken()
getGenerateTokenFunction()
getToken()
Gets the anti-csrf token from the session.
getTokenBytesLength()
getTokenName()
Gets the anti-csrf token name.
getUserToken()
Gets the user token from the request input form.
input()
Gets the HTML form hidden input if the verification is enabled.
isEnabled()
Tells if the verification is enabled.
isSafeMethod()
Safe HTTP Request methods are: GET, HEAD and OPTIONS.
setGenerateTokenFunction()
- string $function
setToken()
Sets the anti-csrf token into the session.
- ?string $token - A custom anti-csrf token or null to generate one
setTokenBytesLength()
- int $length
setTokenName()
Sets the anti-csrf token name.
- string $tokenName
validate()
Validates if a user token is equals the session token.
This method can be used to validate tokens not received through forms.
For example: Through a request header, JSON, etc.
- string $userToken
verify()
Verifies the request input token, if the verification is enabled. The verification always succeed on HTTP GET, HEAD and OPTIONS methods. If verification is successful with other HTTP methods, a new token is generated.
isVerified()
setVerified()
- bool $status