CSRFP
in package
Contains a mechanism for validating requests.
Table of Contents
Methods
- __construct() : CSRFP
- Creates a new CSRFP instance.
- createToken() : string
- Creates a token string.
- verifyToken() : bool
- Verifies a token string.
Methods
__construct()
Creates a new CSRFP instance.
public
__construct(string $secretKey, string $identity[, int $tolerance = self::TOLERANCE ]) : CSRFP
Parameters
- $secretKey : string
-
Secret key for HMAC hashes.
- $identity : string
-
Unique identity component for these tokens.
- $tolerance : int = self::TOLERANCE
-
Default amount of time a token should remain valid for.
Return values
CSRFP —New CSRFP instance.
createToken()
Creates a token string.
public
createToken([int $time = -1 ]) : string
Parameters
- $time : int = -1
-
Timestamp to generate the token for, -1 (default) for now.
Return values
string —Token string.
verifyToken()
Verifies a token string.
public
verifyToken(string $token[, int $tolerance = -1 ][, int $time = -1 ]) : bool
Parameters
- $token : string
-
Token to test.
- $tolerance : int = -1
-
Amount of seconds for which the token can remain valid, < 0 for whatever the default value is.
- $time : int = -1
-
Point in time for which to check validity for this time.
Return values
bool —true if the token is valid, false if not.