adachsoft / oidc-provider-web-token
ES256 signing-key generation, JWT signing, and token verification for OIDC provider applications.
Package info
gitlab.com/a.adach/oidc-provider-web-token
pkg:composer/adachsoft/oidc-provider-web-token
Requires
- php: ^8.3
- adachsoft/oidc-provider-contracts: ^0.1
- web-token/jwt-library: ^4.2
Requires (Dev)
- adachsoft/php-code-style: ^0.7.4
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13
- rector/rector: ^2.9
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
adachsoft/oidc-provider-web-token implements the signing-key generator, token signer, and token verifier contracts from adachsoft/oidc-provider-contracts using web-token/jwt-library. All key generation, signing, and signature verification are delegated to web-token.
Requirements and installation
- PHP
^8.3 adachsoft/oidc-provider-contracts:^0.1web-token/jwt-library:^4.2(the latest stable release compatible with PHP 8.3)
Install the adapter with Composer:
composer require adachsoft/oidc-provider-web-token
Usage
Wiring
Register the adapter implementations for the corresponding contracts and provide your application's repository, clock, key-ID, token, and claims services:
use AdachSoft\OidcProviderContracts\Dto\ProviderPolicyDto;
use AdachSoft\OidcProviderContracts\Service\SigningKeyService;
use AdachSoft\OidcProviderContracts\Service\TokenIssuer;
use AdachSoft\OidcProviderWebToken\WebTokenSigner;
use AdachSoft\OidcProviderWebToken\WebTokenSigningKeyGenerator;
use AdachSoft\OidcProviderWebToken\WebTokenVerifier;
use DateInterval;
$keyGenerator = new WebTokenSigningKeyGenerator();
$signer = new WebTokenSigner();
$verifier = new WebTokenVerifier();
$signingKeys = new SigningKeyService(
$signingKeyRepository,
$keyGenerator,
$keyIdGenerator,
$clock,
new DateInterval('P2D'),
);
$tokenIssuer = new TokenIssuer(
$signer,
$signingKeys,
$clock,
new ProviderPolicyDto('https://identity.example.com'),
$tokenGenerator,
$refreshTokenRepository,
$claimsProvider,
);
Use TokenVerifierInterface consumers with the published keys and an explicit issuer, audience, time, and leeway expectation. JwksDocumentFactory from oidc-provider-contracts can publish the same keys as a public JWKS document.
Key format and supported algorithm
The adapter currently supports ES256 with EC P-256 keys. A signing key's opaque privateKey value is the full private JWK serialized as JSON; its public JWK contains only kty, crv, x, y, kid, alg, and use.
Treat the private JWK JSON as a secret: restrict access, avoid logging it, and protect it at rest. Only the public JWK is used when verifying signatures.
Security notes
- Verification pins the JWS
algto the selected key's algorithm and supports only ES256. - The
nonealgorithm and HMAC algorithms are rejected; algorithm negotiation from an untrusted token is not allowed. - Verification constructs its cryptographic key from the key record's public JWK and never loads
privateKey. - Tokens are accepted only after signature, issuer, audience, expiration, not-before, and issued-at checks succeed.