Repository navigation
How to introspect an ID token without a TokenEndpointResponse
#897
|
This library used to contain methods for introspecting claims from an ID token without a Edit: it looks like the |
Replies: 1 comment
|
Not with an openid-client v6 function. v6 only validates ID tokens as part of a flow ( The remote-keystore part is what import * as client from 'openid-client'
import { createRemoteJWKSet, jwtVerify } from 'jose'
const config = await client.discovery(new URL(issuerUrl), clientId)
const { issuer, jwks_uri } = config.serverMetadata()
const JWKS = createRemoteJWKSet(new URL(jwks_uri!)) // create once, it caches keys
const { payload } = await jwtVerify(idToken, JWKS, {
issuer,
audience: clientId,
algorithms: ['RS256'], // whatever your client's id_token_signed_response_alg is
requiredClaims: ['sub', 'iat', 'exp'],
})This checks the signature against the provider's JWKS (and refetches when it sees an unknown |
Not with an openid-client v6 function. v6 only validates ID tokens as part of a flow (
authorizationCodeGrant,refreshTokenGrant,implicitAuthentication, and so on), and none of its exports takes a bare ID token (src/index.ts).The remote-keystore part is what
josedoes, and openid-client already depends on it (package.json#L91-L94). Since you import it directly, add it to your own dependencies too (npm i jose). Get the issuer andjwks_urifrom discovery, then verify: