Property | Type | Description | |
---|---|---|---|
$_params | array | Hash of parameters necessary to use the chosen backend. |
Method | Description | |
---|---|---|
__construct ( array $params ) | Constructor. | |
add ( string $tokenID ) | Add a token ID. | |
exists ( string $tokenID ) : boolean | Does the token exist? | |
get ( string $seed = '' ) : string | Return a new signed token. | |
getNonce ( ) : string | Return a "number used once" (a concatenation of a timestamp and a random numer). | |
isValid ( string $token, string $seed = '', integer $timeout = null, boolean $unique = false ) : boolean | Validate a signed token. | |
purge ( ) | Delete all expired connection IDs. | |
validate ( string $token, string $seed = '', integer $timeout = null ) : array | Is the given token still valid? Throws an exception in case it is not. | |
validateUnique ( string $token, string $seed = '' ) : null | Is the given token valid and has never been used before? Throws an exception otherwise. | |
verify ( string $token ) : boolean | Checks if the given token has been previously used. First purges all expired tokens. Then retrieves current tokens for the given ip address. If the specified token was not found, adds it. |
Method | Description | |
---|---|---|
_encodeRemoteAddress ( ) : string | Encodes the remote address. |
Method | Description | |
---|---|---|
_decode ( string $token ) : array | Decode a token into the prefixed nonce and the hash. | |
_hash ( string $text ) : string | Sign the given text with the secret. | |
_isExpired ( string $nonce, integer $timeout ) : boolean | Has the nonce expired? |
public __construct ( array $params ) | ||
$params | array | Required parameters: - secret (string): The secret string used for signing tokens. Optional parameters: - token_lifetime (integer): The number of seconds after which tokens time out. Negative numbers represent "no timeout". The default is "-1". - timeout (integer): The period (in seconds) after which an id is purged. DEFAULT: 86400 (24 hours) |
protected _encodeRemoteAddress ( ) : string | ||
return | string | Encoded address. |
public isValid ( string $token, string $seed = '', integer $timeout = null, boolean $unique = false ) : boolean | ||
$token | string | The signed token. |
$seed | string | The unique ID of the token. |
$timeout | integer | Timout of the token in seconds. Values below zero represent no timeout. |
$unique | boolean | Should validation of the token succeed only once? |
return | boolean | True if the token was valid. |
public validate ( string $token, string $seed = '', integer $timeout = null ) : array | ||
$token | string | The signed token. |
$seed | string | The unique ID of the token. |
$timeout | integer | Timout of the token in seconds. Values below zero represent no timeout. |
return | array | An array of two elements: The nonce and the hash. |
protected array $_params | ||
return | array |