class Storage (View source)

Confirmation Storage implemented on top of SilverStripe Session and Cookie

The storage keeps the information about the items requiring confirmation and their status (confirmed or not) in Session

User data, such as the original request parameters, may be kept in Cookie so that session storage cannot be exhausted easily by a malicious user

Constants

HASH_ALGO

Methods

__construct(Session $session, string $id, bool $new = true)

No description

cleanup()

Remove all the data from the storage Cleans up Session and Cookie related to this storage

bool
confirm(array $data)

Gets user input data (usually POST array), checks all the items in the storage has been confirmed and marks them as such.

array
getHashedItems()

Returns the dictionary with the item hashes

string
getTokenHash(Item $item)

Returns salted and hashed version of the item token

string
getCookieKey()

Returns the unique cookie key generated from the session salt

string
getCsrfToken()

Returns a unique token to use as a CSRF token

string
getSessionSalt()

Returns the salt generated for the current session

$this
putItem(Item $item)

Adds a new object to the list of confirmation items Replaces the item if there is already one with the same token

Item[]
getItems()

Returns the list of registered confirmation items

null|Item
getItem(string $key)

Look up an item by its token key

$this
setSuccessRequest(HTTPRequest $request)

This request should be performed on success Usually the original request which triggered the confirmation

string
getHttpMethod()

Returns HTTP method of the success request

array|null
getSuccessPostVars()

Returns the list of success request post parameters

setSuccessUrl(string $url)

The URL the form should redirect to on success

string
getSuccessUrl()

Returns the URL registered by {see self::setSuccessUrl} as a success redirect target

setFailureUrl(string $url)

The URL the form should redirect to on failure

string
getFailureUrl()

Returns the URL registered by {see self::setFailureUrl} as a success redirect target

bool
check(array $items)

Check all items to be confirmed in the storage

Details

__construct(Session $session, string $id, bool $new = true)

Parameters

Session $session

active session

string $id

Unique storage identifier within the session

bool $new

Cleanup the storage

cleanup()

Remove all the data from the storage Cleans up Session and Cookie related to this storage

bool confirm(array $data)

Gets user input data (usually POST array), checks all the items in the storage has been confirmed and marks them as such.

Parameters

array $data

User input to look at for items. Usually POST array

Return Value

bool

whether all items have been confirmed

array getHashedItems()

Returns the dictionary with the item hashes

The {see \SilverStripe\Security\Confirmation\SilverStripe\Security\Confirmation\Storage::confirm} function expects exactly same dictionary as its argument for successful confirmation

Keys of the dictionary are salted item token hashes All values are the string "1" constantly

Return Value

array

string getTokenHash(Item $item)

Returns salted and hashed version of the item token

Parameters

Item $item

Return Value

string

string getCookieKey()

Returns the unique cookie key generated from the session salt

Return Value

string

string getCsrfToken()

Returns a unique token to use as a CSRF token

Return Value

string

string getSessionSalt()

Returns the salt generated for the current session

Return Value

string

$this putItem(Item $item)

Adds a new object to the list of confirmation items Replaces the item if there is already one with the same token

Parameters

Item $item

Item requiring confirmation

Return Value

$this

Item[] getItems()

Returns the list of registered confirmation items

Return Value

Item[]

null|Item getItem(string $key)

Look up an item by its token key

Parameters

string $key

Item token key

Return Value

null|Item

$this setSuccessRequest(HTTPRequest $request)

This request should be performed on success Usually the original request which triggered the confirmation

Parameters

HTTPRequest $request

Return Value

$this

string getHttpMethod()

Returns HTTP method of the success request

Return Value

string

array|null getSuccessPostVars()

Returns the list of success request post parameters

Returns null if no parameters was persisted initially or if the checksum is incorrect.

WARNING! If HTTP Method is POST and this function returns null, you MUST assume the Cookie parameter either has been forged or expired.

Return Value

array|null

setSuccessUrl(string $url)

The URL the form should redirect to on success

Parameters

string $url

Success URL

string getSuccessUrl()

Returns the URL registered by {see self::setSuccessUrl} as a success redirect target

Return Value

string

setFailureUrl(string $url)

The URL the form should redirect to on failure

Parameters

string $url

Failure URL

string getFailureUrl()

Returns the URL registered by {see self::setFailureUrl} as a success redirect target

Return Value

string

bool check(array $items)

Check all items to be confirmed in the storage

Parameters

array $items

List of items to be checked

Return Value

bool