class Storage

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

$this;
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

$this;
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

at line 42
__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

at line 61
cleanup()

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

at line 75
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

at line 103
array getHashedItems()

Returns the dictionary with the item hashes

The {see 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

at line 123
string getTokenHash(Item $item)

Returns salted and hashed version of the item token

Parameters

Item $item

Return Value

string

at line 138
string getCookieKey()

Returns the unique cookie key generated from the session salt

Return Value

string

at line 150
string getCsrfToken()

Returns a unique token to use as a CSRF token

Return Value

string

at line 162
string getSessionSalt()

Returns the salt generated for the current session

Return Value

string

at line 192
$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

at line 210
Item[] getItems()

Returns the list of registered confirmation items

Return Value

Item[]

at line 222
null|Item getItem(string $key)

Look up an item by its token key

Parameters

string $key Item token key

Return Value

null|Item

at line 239
$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

at line 293
string getHttpMethod()

Returns HTTP method of the success request

Return Value

string

at line 310
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

at line 364
$this; setSuccessUrl(string $url)

The URL the form should redirect to on success

Parameters

string $url Success URL

Return Value

$this;

at line 375
string getSuccessUrl()

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

Return Value

string

at line 387
$this; setFailureUrl(string $url)

The URL the form should redirect to on failure

Parameters

string $url Failure URL

Return Value

$this;

at line 398
string getFailureUrl()

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

Return Value

string

at line 410
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