Token
in package
implements
TokenInterface
Table of Contents
Interfaces
Constants
- ALGO_HS256 : string = 'HS256'
- ALGO_HS384 : string = 'HS384'
- ALGO_HS512 : string = 'HS512'
- ALGO_RS256 : string = 'RS256'
- ALGO_RS384 : string = 'RS384'
- ALGO_RS512 : string = 'RS512'
- MAX_AGE_SKIP : int = -1
- Sentinel for `$tokenMaxAge` that skips the `auth_time` check for flows with no interactive `max_age`, such as token exchange.
- TYPE_ACCESS_TOKEN : int = 2
- TYPE_ID_TOKEN : int = 1
- TYPE_LOGOUT_TOKEN : int = 3
- TYPE_TOKEN : mixed = 2
Properties
- $configuration : SdkConfiguration
- $jwt : string
- $parser : Parser|null
- $type : int
Methods
- __construct() : mixed
- Constructor for Token handling class.
- getAudience() : null|array<string|int, string>
- 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.
- getEvents() : null|array<string|int, mixed>
- Get the contents of the 'events' claim. Null if not present.
- getExpiration() : int|null
- Get the contents of the 'exp' claim. Null if not present.
- getIdentifier() : string|null
- Get the contents of the 'sid' 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.
- getOrganizationId() : string|null
- getOrganizationName() : string|null
- 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
string
ALGO_HS256
= 'HS256'
ALGO_HS384
public
string
ALGO_HS384
= 'HS384'
ALGO_HS512
public
string
ALGO_HS512
= 'HS512'
ALGO_RS256
public
string
ALGO_RS256
= 'RS256'
ALGO_RS384
public
string
ALGO_RS384
= 'RS384'
ALGO_RS512
public
string
ALGO_RS512
= 'RS512'
MAX_AGE_SKIP
Sentinel for `$tokenMaxAge` that skips the `auth_time` check for flows with no interactive `max_age`, such as token exchange.
public
int
MAX_AGE_SKIP
= -1
TYPE_ACCESS_TOKEN
public
int
TYPE_ACCESS_TOKEN
= 2
TYPE_ID_TOKEN
public
int
TYPE_ID_TOKEN
= 1
TYPE_LOGOUT_TOKEN
public
int
TYPE_LOGOUT_TOKEN
= 3
TYPE_TOKEN
Use TYPE_ACCESS_TOKEN instead.
public
mixed
TYPE_TOKEN
= 2
Properties
$configuration read-only
private
SdkConfiguration
$configuration
$jwt read-only
private
string
$jwt
$parser
private
Parser|null
$parser
= null
$type read-only
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
getAudience()
Get the contents of the 'aud' claim, always returned an array. Null if not present.
public
getAudience() : null|array<string|int, string>
Return values
null|array<string|int, string>getAuthorizedParty()
Get the contents of the 'azp' claim. Null if not present.
public
getAuthorizedParty() : string|null
Return values
string|nullgetAuthTime()
Get the contents of the 'auth_time' claim. Null if not present.
public
getAuthTime() : int|null
Return values
int|nullgetEvents()
Get the contents of the 'events' claim. Null if not present.
public
getEvents() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>getExpiration()
Get the contents of the 'exp' claim. Null if not present.
public
getExpiration() : int|null
Return values
int|nullgetIdentifier()
Get the contents of the 'sid' claim. Null if not present.
public
getIdentifier() : string|null
Return values
string|nullgetIssued()
Get the contents of the 'iat' claim. Null if not present.
public
getIssued() : int|null
Return values
int|nullgetIssuer()
Get the contents of the 'iss' claim. Null if not present.
public
getIssuer() : string|null
Return values
string|nullgetNonce()
Get the contents of the 'nonce' claim. Null if not present.
public
getNonce() : string|null
Return values
string|nullgetOrganization()
Get the contents of the 'org_id' claim. Null if not present.
public
getOrganization() : string|null
Return values
string|nullgetOrganizationId()
public
getOrganizationId() : string|null
Return values
string|nullgetOrganizationName()
public
getOrganizationName() : string|null
Return values
string|nullgetSubject()
Get the contents of the 'sub' claim. Null if not present.
public
getSubject() : string|null
Return values
string|nullparse()
Parses a provided JWT string and prepare for verification and validation.
public
parse() : self
Return values
selftoArray()
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
stringvalidate()
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
selfverify()
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
selfgetParser()
private
getParser() : Parser