MCP PHP SDK

JwksProvider implements JwksProviderInterface

Loads JWKS key sets from explicit URI or discovered issuer metadata.

Tags
author

Volodymyr Panivko sveneld300@gmail.com

Table of Contents

Interfaces

JwksProviderInterface
Contract for loading JWKS key sets used for JWT signature verification.

Constants

CACHE_KEY_PREFIX  = 'mcp_jwks_'

Properties

$cache  : CacheInterface|null
$cacheTtl  : int
$discovery  : OidcDiscoveryInterface
$httpClient  : ClientInterface
$requestFactory  : RequestFactoryInterface

Methods

__construct()  : mixed
getJwks()  : array<string, mixed>
fetchJwks()  : array<string, mixed>
isJwksValid()  : bool

Constants

CACHE_KEY_PREFIX

private mixed CACHE_KEY_PREFIX = 'mcp_jwks_'

Properties

$cache read-only

private CacheInterface|null $cache = null

$requestFactory

private RequestFactoryInterface $requestFactory

Methods

__construct()

public __construct(OidcDiscoveryInterface $discovery[, ClientInterface|null $httpClient = null ][, RequestFactoryInterface|null $requestFactory = null ][, CacheInterface|null $cache = null ][, int $cacheTtl = 3600 ]) : mixed
Parameters
$discovery : OidcDiscoveryInterface

OIDC discovery provider (required for JWKS URI resolution when $jwksUri is not explicit)

$httpClient : ClientInterface|null = null

PSR-18 HTTP client (auto-discovered if null)

$requestFactory : RequestFactoryInterface|null = null

PSR-17 request factory (auto-discovered if null)

$cache : CacheInterface|null = null

Optional PSR-16 cache

$cacheTtl : int = 3600

JWKS cache TTL in seconds

getJwks()

public getJwks(string $issuer[, string|null $jwksUri = null ]) : array<string, mixed>
Parameters
$issuer : string

authorization server issuer URL

$jwksUri : string|null = null

Optional explicit JWKS URI. If null, implementation may resolve via discovery.

Return values
array<string, mixed>

fetchJwks()

private fetchJwks(string $jwksUri) : array<string, mixed>
Parameters
$jwksUri : string
Return values
array<string, mixed>

isJwksValid()

private isJwksValid(mixed $jwks) : bool
Parameters
$jwks : mixed
Return values
bool

        
On this page

Search results