Skip to content

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

Open
QuellcodeWanderer wants to merge 1 commit into
keycloak:mainfrom
QuellcodeWanderer:ec-eddsa-configurable-kid
Open

QuellcodeWanderer wants to merge 1 commit into
keycloak:mainfrom
QuellcodeWanderer:ec-eddsa-configurable-kid

Conversation

@QuellcodeWanderer

Copy link
Copy Markdown
Contributor

I used the same mechanism the RSA key providers already have since #15114: if the component configuration contains kid, it is used as the key ID, otherwise the key ID is still derived from the public key. I chose this over a new, visible config property to keep the key providers consistent and the change minimal. Existing EC and EdDSA keys keep their derived key IDs, because none of them has kid in their configuration.

As with RSA, kid is not a declared config property. It is therefore not shown in the admin console and can only be set when the component is created, through the Admin REST API or a realm import. An update through the Admin REST API ignores undeclared keys, so the stored kid stays as it is. When the curve is changed and the key is regenerated, the configured kid is kept. If you prefer kid to be a declared, visible property for all asymmetric key providers, I can do that in a follow-up.

The tests cover the default (the key ID is still KeyUtils.createKeyId() of the public key) and a configured kid for ecdsa-generated, ecdh-generated and eddsa-generated, including the curve change for ecdsa-generated. eddsa-generated had no test class in tests/base yet, so I added GeneratedEddsaKeyProviderTest.

Closes #55278

Closes keycloak#55278

Signed-off-by: Maximilian Brodda <QuellcodeWanderer@users.noreply.github.com>
@QuellcodeWanderer
QuellcodeWanderer requested a review from a team as a code owner November 17, 2026 16:09
Copilot AI balanced review requested due to automatic review settings November 17, 2026 16:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change aligning EC and EdDSA key ID handling with existing RSA behavior.

No open issues 🎉

What changed in this PR

Addresses #55278 by aligning generated EC and EdDSA key IDs with the existing RSA behavior, without adding an admin-console setting.

Changes:

  • Uses the configured kid when present; otherwise preserves public-key-derived IDs.
  • Adds tests for custom IDs across ECDSA, ECDH and EdDSA, default IDs for ECDSA and EdDSA, and ID preservation after an ECDSA curve change.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​keys/​GeneratedEddsaKeyProviderTest.java Adds default and custom EdDSA key ID tests.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​keys/​GeneratedEcdsaKeyProviderTest.java Tests default IDs, custom IDs and preservation across curve changes.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​keys/​GeneratedEcdhKeyProviderTest.java Tests custom ECDH key IDs.
services/​src/​main/​java/​org/​keycloak/​keys/​AbstractEddsaKeyProvider.java Honors configured EdDSA IDs with the existing derivation as fallback.
services/​src/​main/​java/​org/​keycloak/​keys/​AbstractEcKeyProvider.java Honors configured ECDSA and ECDH IDs with the existing derivation as fallback.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow configuring the key ID of generated EC and EdDSA keys

2 participants