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" }

The generated jwkProvider exposes only the public key. Token helpers sign with the matching private key.

HMAC algorithms are intentionally unsupported.

Report a problem

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

signing algorithm used by the public token helpers.

Link copied to clipboard
val jwkProvider: JwkProvider

JWK provider backed by this in-memory public key.

Link copied to clipboard

key ID written to token headers and exposed by the generated JWK.

Functions

Link copied to clipboard

Issues a signed JWT access token.

Link copied to clipboard
fun idToken(subject: String, configure: OpenIdTestIdTokenBuilder.() -> Unit = {}): String

Issues a signed ID token.