Documentation

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

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
throws
InternalError

when CSRFName is expected and not found

throws
InternalError

when token or name is not as stored in session

psalm-suppress

PossiblyUnusedMethod

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
template

object

psalm-return

object

psalm-suppress

MismatchingDocblockReturnType

psalm-suppress

ReservedWord

Return values
object

inputs()

Return HTML inputs for CSRF

public inputs() : string
Tags
psalm-suppress

PossiblyUnusedMethod

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

Return values
bool

Search results