Leaf PHP

CSRF extends Anchor
in package

Leaf CSRF Module ---------------- Add CSRF protection to your app

Tags
since
3.0.0

Table of Contents

Properties

$config  : mixed
$errors  : mixed

Methods

config()  : mixed
Manage config for leaf anchor
deepGet()  : mixed
Get an item or items from an array of data.
deepGetDot()  : mixed
Deep get an item or items from an array of data using dot notation.
deepSetDot()  : mixed
Deep set an item or items in an array of data using dot notation.
deepUnsetDot()  : mixed
Deep unset an item or items in an array of data using dot notation.
errors()  : array<string|int, mixed>
form()  : mixed
generateToken()  : string
Generate a token for identifying your application
getPathExpression()  : mixed
init()  : mixed
sanitize()  : mixed
Escape malicious characters
toBool()  : bool
Convert string to boolean. Created due to inconsistencies in PHP's boolval and (bool)
token()  : mixed
validate()  : mixed
Validate the CSRF token and run associated handler
verify()  : bool
Validate the CSRF token

Properties

$config

protected static mixed $config = ['secret' => '@nkor_leaf$0Secret!!', 'secretKey' => 'X-Leaf-CSRF-Token', 'except' => [], 'methods' => ['POST', 'PUT', 'PATCH', 'DELETE'], 'messages.tokenNotFound' => 'Token not found.', 'messages.tokenInvalid' => 'Invalid token.', 'onError' => null]

$errors

protected static mixed $errors = []

Methods

config()

Manage config for leaf anchor

public static config([array<string|int, mixed>|null $config = null ]) : mixed
Parameters
$config : array<string|int, mixed>|null = null

The config to set

deepGet()

Get an item or items from an array of data.

public static deepGet(array<string|int, mixed> $dataSource[, string|array<string|int, mixed> $item = null ]) : mixed
Parameters
$dataSource : array<string|int, mixed>

An array of data to search through

$item : string|array<string|int, mixed> = null

The items to return

deepGetDot()

Deep get an item or items from an array of data using dot notation.

public static deepGetDot(array<string|int, mixed> $dataSource[, string|array<string|int, mixed> $item = null ]) : mixed
Parameters
$dataSource : array<string|int, mixed>

An array of data to search through

$item : string|array<string|int, mixed> = null

The items to return

deepSetDot()

Deep set an item or items in an array of data using dot notation.

public static deepSetDot(array<string|int, mixed> $dataSource, string|array<string|int, mixed> $item[, mixed $value = null ]) : mixed
Parameters
$dataSource : array<string|int, mixed>

An array of data to search through

$item : string|array<string|int, mixed>

The items to set

$value : mixed = null

The value to set

deepUnsetDot()

Deep unset an item or items in an array of data using dot notation.

public static deepUnsetDot(mixed $dataSource, mixed $item) : mixed
Parameters
$dataSource : mixed
$item : mixed

errors()

public static errors() : array<string|int, mixed>
Return values
array<string|int, mixed>

form()

public static form() : mixed

generateToken()

Generate a token for identifying your application

public static generateToken([int $strength = 16 ]) : string
Parameters
$strength : int = 16

Number of random characters to attach to token

Return values
string

getPathExpression()

public static getPathExpression(mixed $url) : mixed
Parameters
$url : mixed

init()

public static init() : mixed

sanitize()

Escape malicious characters

public static sanitize(mixed $data) : mixed
Parameters
$data : mixed

The data to sanitize.

toBool()

Convert string to boolean. Created due to inconsistencies in PHP's boolval and (bool)

public static toBool(string $value) : bool
Parameters
$value : string

The value to convert

Return values
bool

token()

public static token() : mixed

validate()

Validate the CSRF token and run associated handler

public static validate() : mixed

verify()

Validate the CSRF token

public static verify() : bool
Return values
bool

        
On this page

Search results