OpenIdTestKeys
Local signing keys for OpenID Connect tests.
Use this utility to issue JWT access tokens and ID tokens that pass normal OIDC validation without contacting a real discovery endpoint or JWKS endpoint. Pair it with static OpenIdProviderMetadata and OidcProviderConfig.jwt to keep issuer, audience, algorithm, and signature checks enabled in tests:
val keys = OpenIdTestKeys.rsa(issuer = TEST_ISSUER, audience = TEST_AUDIENCE)
// Static metadata skips discovery; jwt(keys) verifies signatures against the in-memory public key.
val provider = oidc.identityProvider("test") {
issuer = TEST_ISSUER
metadata = OpenIdProviderMetadata(
issuer = TEST_ISSUER,
authorizationEndpoint = "$TEST_ISSUER/authorize",
tokenEndpoint = "$TEST_ISSUER/token",
jwksUri = "$TEST_ISSUER/jwks",
)
jwt(keys)
bearer { audience = setOf(TEST_AUDIENCE) }
}
val token = keys.accessToken { subject = "user-1" }
val idToken = keys.idToken(subject = "user-1") { audience = "client-id" }Content copied to clipboard
The generated jwkProvider exposes only the public key. Token helpers sign with the matching private key.
HMAC algorithms are intentionally unsupported.