class CsrfGuard (View source)

The CsrfManager class.

Constants

TOKEN_KEY

Methods

__construct(Config $config, Input $input, Session $session, UserManager $userManager)

CsrfGuard constructor.

bool
validate(bool $justDie = false, string $message = 'Invalid Token')

Validate token or die.

HtmlElement
input(mixed $userId = null, array $attribs = array())

Create token input.

string
createToken(int $length = 12)

Create token string.

string
getToken(boolean $forceNew = false)

Get form token string.

string
getFormToken(mixed $userId = null, boolean $forceNew = false)

Get a token for specific user.

boolean
checkToken(mixed $userId = null, string $method = null)

checkToken

Details

at line line 60
__construct(Config $config, Input $input, Session $session, UserManager $userManager)

CsrfGuard constructor.

Parameters

Config $config
Input $input
Session $session
UserManager $userManager

at line line 76
bool validate(bool $justDie = false, string $message = 'Invalid Token')

Validate token or die.

Parameters

bool $justDie
string $message

Return Value

bool

at line line 99
HtmlElement input(mixed $userId = null, array $attribs = array())

Create token input.

Parameters

mixed $userId
array $attribs

Return Value

HtmlElement

at line line 115
string createToken(int $length = 12)

Create token string.

Parameters

int $length Token string length.

Return Value

string

at line line 140
string getToken(boolean $forceNew = false)

Get form token string.

Parameters

boolean $forceNew Force create new token.

Return Value

string

Exceptions

UnexpectedValueException
RuntimeException

at line line 168
string getFormToken(mixed $userId = null, boolean $forceNew = false)

Get a token for specific user.

Parameters

mixed $userId An identify of current user.
boolean $forceNew Force create new token.

Return Value

string

Exceptions

RuntimeException
UnexpectedValueException

at line line 188
boolean checkToken(mixed $userId = null, string $method = null)

checkToken

Parameters

mixed $userId
string $method

Return Value

boolean

Exceptions

RuntimeException
UnexpectedValueException