Repository navigation
Allow configuring the key ID of generated EC and EdDSA keys - #55280
Open
QuellcodeWanderer wants to merge 1 commit into
Open
QuellcodeWanderer wants to merge 1 commit into
QuellcodeWanderer wants to merge 1 commit into
Conversation
Closes keycloak#55278 Signed-off-by: Maximilian Brodda <QuellcodeWanderer@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 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
kidwhen 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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