CSRFGuard
in package
Uses
Singleton
Contains definition of CRSFGuard class
Table of Contents
- NAME = 'CSRFName'
- STRENGTH = 64
- TOKEN = 'CSRFToken'
- $instance : object
- The only instance of using class
- check() : void
- Check a form
- generate() : array<, mixed>
- Generate a name and a token
- getinstance() : object
- Checks, instantiates and returns the only instance of the using class.
- inputs() : string
- Return HTML inputs for CSRF
- maketoken() : string
- Generate unique token
- validate() : bool
- Validate token
Constants
NAME
private
mixed
NAME
= 'CSRFName'
STRENGTH
private
mixed
STRENGTH
= 64
TOKEN
private
mixed
TOKEN
= 'CSRFToken'
Properties
$instance
The only instance of using class
protected
static object
$instance
= NULL
Methods
check()
Check a form
public
check([int $type = INPUT_POST ]) : void
Parameters
- $type : int = INPUT_POST
-
Defaults to INPUT_POST, but could be INPUT_GET
Tags
Return values
void —generate()
Generate a name and a token
public
generate() : array<, mixed>
Return values
array<, mixed> —getinstance()
Checks, instantiates and returns the only instance of the using class.
public
static getinstance() : object
Tags
Return values
object —inputs()
Return HTML inputs for CSRF
public
inputs() : string
Tags
Return values
string —maketoken()
Generate unique token
private
maketoken(string $uname) : string
Parameters
- $uname : string
-
The name to be used for storing the token into the Session data
Return values
string —The token
validate()
Validate token
private
validate(string $uname, string $tocheck) : bool
Parameters
- $uname : string
-
The name to be used for storing the token into the Session data
- $tocheck : string
-
The token to be compared with what is stored