Skip to content

Allow configuring the key ID of generated EC and EdDSA keys #55278

Description

@QuellcodeWanderer

Enhancement Description

The generated ECDSA (ecdsa-generated), ECDH (ecdh-generated) and EdDSA (eddsa-generated) key providers always derive the kid from the public key (Base64url-encoded SHA-256 of the encoded key). The RSA key providers and the Java keystore provider already use the kid from the component configuration when it is set, and fall back to the derived value otherwise. The EC and EdDSA key providers should behave the same.

Value Proposition

Some ecosystems prescribe the format of the key identifiers published in a JWKS. In our deployment, the federation operator requires every kid to be a UUIDv7, because the creation time encoded in the identifier is used to enforce a maximum key lifetime. Today this can only be met with RSA keys or keys from a Java keystore, not with generated EC or EdDSA keys such as ES256, which is the mandated algorithm there.

Goals

When the component configuration of an ecdsa-generated, ecdh-generated or eddsa-generated key provider contains kid, the key uses that value as its key ID in the realm keys and the JWKS. Without it, the key ID is derived from the public key as before.

Non-Goals

Generating key IDs in a specific format (such as UUIDv7) inside Keycloak. Exposing the key ID in the admin console, which the RSA key providers do not do either.

Discussion

No response

Notes

This mirrors the existing behaviour of AbstractRsaKeyProvider, which reads Attributes.KID_KEY from the component model (introduced in #15114). The change is in AbstractEcKeyProvider and AbstractEddsaKeyProvider, so it applies to all three key providers. I'm happy to provide a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    Value

    None yet

    Effort

    None yet

    Votes

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions