Auth0-PHP

Verifier
in package

Class Verifier.

Table of Contents

$algorithm  : string|null
$cache  : CacheItemPoolInterface|null
$cacheExpires  : int|null
$clientSecret  : string|null
$configuration  : SdkConfiguration
$headers  : array<string|int, mixed>
$jwksUri  : string|null
$mockedHttpResponses  : array<string|int, mixed>|null
$payload  : string
$signature  : string
__construct()  : mixed
Constructor for the Token Verifier class.
verify()  : self
Verify the token signature.
freeKey()  : void
Free key resource in PHP <8.0.
getKey()  : OpenSSLAsymmetricKey|resource
Query a JWKS endpoint for a matching key. Parse and return a OpenSSLAsymmetricKey (PHP 8.0+) or resource (PHP < 8.0) suitable for verification.
getKeySet()  : array<int|string, mixed>
Query a JWKS endpoint and return an array representing the key set.

Properties

$algorithm

private string|null $algorithm = null

$cache

private CacheItemPoolInterface|null $cache = null

$cacheExpires

private int|null $cacheExpires = null

$clientSecret

private string|null $clientSecret = null

$headers

private array<string|int, mixed> $headers

$jwksUri

private string|null $jwksUri = null

$mockedHttpResponses

private array<string|int, mixed>|null $mockedHttpResponses = null

Methods

__construct()

Constructor for the Token Verifier class.

public __construct(SdkConfiguration $configuration, string $payload, string $signature, array<string|int, int|string> $headers[, string|null $algorithm = null ][, string|null $jwksUri = null ][, string|null $clientSecret = null ][, int|null $cacheExpires = null ][, CacheItemPoolInterface|null $cache = null ][, array<string|int, object>|null &$mockedHttpResponses = null ]) : mixed
Parameters
$configuration : SdkConfiguration
$payload : string

a string representing the headers and claims portions of a JWT

$signature : string

a string representing the signature portion of a JWT

$headers : array<string|int, int|string>

An array of the headers for the JWT. Expects an 'alg' header, and in the case of RS256, a 'kid' header.

$algorithm : string|null = null

Optional. Algorithm to use for verification. Expects either RS256 or HS256. Defaults to RS256.

$jwksUri : 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.

$cacheExpires : int|null = null

Optional. Time in seconds to keep JWKS records cached.

$cache : CacheItemPoolInterface|null = null

Optional. A PSR-6 CacheItemPoolInterface instance to cache JWKS results within.

$mockedHttpResponses : array<string|int, object>|null = null

Optional. Only intended for unit testing purposes.

Return values
mixed

verify()

Verify the token signature.

public verify() : self
Tags
throws
InvalidTokenException

When signature verification fails. See exception message for details.

psalm-suppress

PossiblyInvalidArgument

Return values
self

freeKey()

Free key resource in PHP <8.0.

private freeKey(mixed $key) : void
Parameters
$key : mixed

An instance of OpenSSLAsymmetricKey (PHP 8.0+) or 'resource' (PHP <8.0).

Tags
codeCoverageIgnore
Return values
void

getKey()

Query a JWKS endpoint for a matching key. Parse and return a OpenSSLAsymmetricKey (PHP 8.0+) or resource (PHP < 8.0) suitable for verification.

private getKey(string $kid) : OpenSSLAsymmetricKey|resource
Parameters
$kid : string

the 'kid' header value to use for key lookup

Tags
throws
InvalidTokenException

When unable to retrieve key. See error message for details.

psalm-suppress

UndefinedDocblockClass

Return values
OpenSSLAsymmetricKey|resource

getKeySet()

Query a JWKS endpoint and return an array representing the key set.

private getKeySet([string|null $expectsKid = null ]) : array<int|string, mixed>
Parameters
$expectsKid : string|null = null

Optional. A key id we're currently expecting to retrieve. When retrieving a cache response, if the key isn't present, it will invalid the cache and fetch an updated JWKS.

Tags
throws
InvalidTokenException

when the JWKS uri is not properly configured, or is unreachable

Return values
array<int|string, mixed>

Search results