Class OidcTokenMinter
Token minting was moved out of OidcProviderGenerator.generate(org.mockserver.oidc.OidcProviderConfiguration) so that per-request
context — most importantly the nonce echoed back from the /authorize request — can
be embedded into the id_token. The provider carries its AsymmetricKeyPair (and the
JWTGenerator built from it) on OidcAuthorizationStore.Provider; the same key both
signs here and is published at the JWKS endpoint, preserving the sign/publish invariant.
Claim split (per OIDC core):
- id_token —
iss, sub, aud=clientId, exp, iat, nbf, nonce(when supplied), profile/email claims for the requested scopes,at_hash, plus additionalClaims. Only issued when theopenidscope was requested. - access_token —
iss, sub, aud=audience, exp, iat, nbf, scope, client_idplus additionalClaims.
-
Constructor Summary
ConstructorsConstructorDescriptionOidcTokenMinter(OidcProviderConfiguration config, AsymmetricKeyPair keyPair) -
Method Summary
Modifier and TypeMethodDescriptionThe JWS algorithm this provider signs with, advertised in the discovery document.mintTokenResponse(String requestedScope, String nonce, boolean includeRefresh) Mints a token response without a request to derive the issuer from.mintTokenResponse(String requestedScope, String nonce, boolean includeRefresh, String issuer) Mints a token-endpoint response using an explicitly resolved issuer.verifyAccessToken(String token) Verifies a JWT access token that this minter issued, returning its claims when the token is genuinely valid andnullwhen it is not.
-
Constructor Details
-
OidcTokenMinter
-
-
Method Details
-
verifyAccessToken
Verifies a JWT access token that this minter issued, returning its claims when the token is genuinely valid andnullwhen it is not.This is the validation path behind
OidcIntrospectionCallback. Introspection previously ignored the presented token entirely for JWT providers and reportedactivefrom static configuration, so any string — garbage, expired, tampered or revoked — introspected as active. A test asserting "my application rejects a revoked token" therefore passed while proving nothing. Introspection is a security control, so it must fail closed: anything that does not verify against this provider's signing key, within its validity window, is inactive.Checks applied, all of which must pass:
- the token parses as a JWS and its signature verifies against this provider's key pair (so a token minted by another provider, or one whose signature was tampered with, fails);
expis in the future andnbf/iatare not in the future, allowingCLOCK_SKEW_SECONDSof skew.
- Parameters:
token- the presented access token- Returns:
- the token's claims when valid, otherwise
null
-
getJwsAlgorithm
The JWS algorithm this provider signs with, advertised in the discovery document. -
mintTokenResponse
Mints a token response without a request to derive the issuer from.Prefer
mintTokenResponse(String, String, boolean, String)whenever a request is available. With no request,OidcIssuerResolvercan only fall back to the configured issuer or, when none is configured, to its hardcoded default — which is precisely the value the per-request derivation exists to avoid. This overload is therefore only appropriate off the request path (e.g. a test minting a token directly). -
mintTokenResponse
public String mintTokenResponse(String requestedScope, String nonce, boolean includeRefresh, String issuer) Mints a token-endpoint response using an explicitly resolved issuer.The issuer is passed in rather than read from configuration because it is resolved per request from the
Hostheader (seeOidcIssuerResolver) — theissclaim in a minted token must match the issuer advertised by the discovery document, or every conformant relying party rejects the token.- Parameters:
issuer- the issuer resolved for this request
-