Token
in package
implements
TokenInterface
Class Token.
Interfaces, Classes, Traits and Enums
- TokenInterface
- Interface TokenInterface.
Table of Contents
- ALGO_HS256 = 'HS256'
- ALGO_RS256 = 'RS256'
- TYPE_ID_TOKEN = 1
- TYPE_TOKEN = 2
- $configuration : SdkConfiguration
- $jwt : string
- $parser : Parser|null
- $type : int
- __construct() : mixed
- Constructor for Token handling class.
- getAudience() : array<string|int, string>|null
- Get the contents of the 'aud' claim, always returned an array. Null if not present.
- getAuthorizedParty() : string|null
- Get the contents of the 'azp' claim. Null if not present.
- getAuthTime() : int|null
- Get the contents of the 'auth_time' claim. Null if not present.
- getExpiration() : int|null
- Get the contents of the 'exp' claim. Null if not present.
- getIssued() : int|null
- Get the contents of the 'iat' claim. Null if not present.
- getIssuer() : string|null
- Get the contents of the 'iss' claim. Null if not present.
- getNonce() : string|null
- Get the contents of the 'nonce' claim. Null if not present.
- getOrganization() : string|null
- Get the contents of the 'org_id' claim. Null if not present.
- getSubject() : string|null
- Get the contents of the 'sub' claim. Null if not present.
- parse() : self
- Parses a provided JWT string and prepare for verification and validation.
- toArray() : array<string|int, mixed>
- Export the state of the Token object as a PHP array.
- toJson() : string
- Export a JSON encoded object (as a string) representing the state of the Token object. Note that this is not itself an ID Token, but is useful for debugging your user state.
- validate() : self
- Validate the claims of the token.
- verify() : self
- Verify the signature of the Token using either RS256 or HS256.
- getParser() : Parser
Constants
ALGO_HS256
public
mixed
ALGO_HS256
= 'HS256'
ALGO_RS256
public
mixed
ALGO_RS256
= 'RS256'
TYPE_ID_TOKEN
public
mixed
TYPE_ID_TOKEN
= 1
TYPE_TOKEN
public
mixed
TYPE_TOKEN
= 2
Properties
$configuration
private
SdkConfiguration
$configuration
$jwt
private
string
$jwt
$parser
private
Parser|null
$parser
= null
$type
private
int
$type
= self::TYPE_ID_TOKEN
Methods
__construct()
Constructor for Token handling class.
public
__construct(SdkConfiguration $configuration, string $jwt[, int $type = self::TYPE_ID_TOKEN ]) : mixed
Parameters
- $configuration : SdkConfiguration
-
Required. Base configuration options for the SDK. See the SdkConfiguration class constructor for options.
- $jwt : string
-
a JWT string to parse, and prepare for verification and validation
- $type : int = self::TYPE_ID_TOKEN
-
Specify the Token type to toggle specific claim validations. Defaults to 1 for ID Token. See TYPE_ consts for options.
Tags
Return values
mixed —getAudience()
Get the contents of the 'aud' claim, always returned an array. Null if not present.
public
getAudience() : array<string|int, string>|null
Return values
array<string|int, string>|null —getAuthorizedParty()
Get the contents of the 'azp' claim. Null if not present.
public
getAuthorizedParty() : string|null
Return values
string|null —getAuthTime()
Get the contents of the 'auth_time' claim. Null if not present.
public
getAuthTime() : int|null
Return values
int|null —getExpiration()
Get the contents of the 'exp' claim. Null if not present.
public
getExpiration() : int|null
Return values
int|null —getIssued()
Get the contents of the 'iat' claim. Null if not present.
public
getIssued() : int|null
Return values
int|null —getIssuer()
Get the contents of the 'iss' claim. Null if not present.
public
getIssuer() : string|null
Return values
string|null —getNonce()
Get the contents of the 'nonce' claim. Null if not present.
public
getNonce() : string|null
Return values
string|null —getOrganization()
Get the contents of the 'org_id' claim. Null if not present.
public
getOrganization() : string|null
Return values
string|null —getSubject()
Get the contents of the 'sub' claim. Null if not present.
public
getSubject() : string|null
Return values
string|null —parse()
Parses a provided JWT string and prepare for verification and validation.
public
parse() : self
Return values
self —toArray()
Export the state of the Token object as a PHP array.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —toJson()
Export a JSON encoded object (as a string) representing the state of the Token object. Note that this is not itself an ID Token, but is useful for debugging your user state.
public
toJson() : string
Return values
string —validate()
Validate the claims of the token.
public
validate([string|null $tokenIssuer = null ][, array<string|int, mixed>|null $tokenAudience = null ][, array<string|int, mixed>|null $tokenOrganization = null ][, string|null $tokenNonce = null ][, int|null $tokenMaxAge = null ][, int|null $tokenLeeway = null ][, int|null $tokenNow = null ]) : self
Parameters
- $tokenIssuer : string|null = null
-
Optional. The value expected for the 'iss' claim.
- $tokenAudience : array<string|int, mixed>|null = null
-
Optional. An array of allowed values for the 'aud' claim. Successful if ANY match.
- $tokenOrganization : array<string|int, mixed>|null = null
-
Optional. An array of allowed values for the 'org_id' claim. Successful if ANY match.
- $tokenNonce : string|null = null
-
Optional. The value expected for the 'nonce' claim.
- $tokenMaxAge : int|null = null
-
Optional. Maximum window of time in seconds since the 'auth_time' to accept the token.
- $tokenLeeway : int|null = null
-
Optional. Leeway in seconds to allow during time calculations. Defaults to 60.
- $tokenNow : int|null = null
-
Optional. Unix timestamp representing the current point in time to use for time calculations.
Return values
self —verify()
Verify the signature of the Token using either RS256 or HS256.
public
verify([string|null $tokenAlgorithm = null ][, string|null $tokenJwksUri = null ][, string|null $clientSecret = null ][, int|null $tokenCacheTtl = null ][, CacheItemPoolInterface|null $tokenCache = null ]) : self
Parameters
- $tokenAlgorithm : string|null = null
-
Optional. Algorithm to use for verification. Expects either RS256 or HS256.
- $tokenJwksUri : string|null = null
-
Optional. URI to the JWKS when verifying RS256 tokens.
- $clientSecret : string|null = null
-
Optional. Client Secret found in the Application settings for verifying HS256 tokens.
- $tokenCacheTtl : int|null = null
-
Optional. Time in seconds to keep JWKS records cached.
- $tokenCache : CacheItemPoolInterface|null = null
-
Optional. A PSR-6 CacheItemPoolInterface instance to cache JWKS results within.
Return values
self —getParser()
private
getParser() : Parser