feat(keycloak_realm_key): add full support for all Keycloak key providers#11468
Open
koke1997 wants to merge 4 commits intoansible-collections:mainfrom
Open
feat(keycloak_realm_key): add full support for all Keycloak key providers#11468koke1997 wants to merge 4 commits intoansible-collections:mainfrom
koke1997 wants to merge 4 commits intoansible-collections:mainfrom
Conversation
Add support for Keycloak's auto-generated key providers where Keycloak manages the key material automatically: - rsa-generated: Auto-generates RSA signing keys - hmac-generated: Auto-generates HMAC signing keys - aes-generated: Auto-generates AES encryption keys - ecdsa-generated: Auto-generates ECDSA signing keys New algorithms: - HMAC: HS256, HS384, HS512 - ECDSA: ES256, ES384, ES512 - AES: AES (no algorithm parameter needed) New config options: - secret_size: For HMAC/AES providers (key size in bytes) - key_size: For RSA-generated provider (key size in bits) - elliptic_curve: For ECDSA-generated provider (P-256, P-384, P-521) Changes: - Make private_key/certificate optional (only required for rsa/rsa-enc) - Add provider-algorithm validation with clear error messages - Fix KeyError when managing default realm keys (issue ansible-collections#11459) - Maintain backward compatibility: RS256 default works for rsa/rsa-generated Fixes: ansible-collections#11459
7a72feb to
4a5c407
Compare
Collaborator
Collaborator
|
The test The test The test The test |
- Add 'default: RS256' to algorithm documentation to match spec - Add no_log=True to secret_size parameter per sanity check
1 task
Add support for remaining auto-generated key providers: - rsa-enc-generated (RSA encryption keys with RSA1_5, RSA-OAEP, RSA-OAEP-256) - ecdh-generated (ECDH key exchange with ECDH_ES, ECDH_ES_A128KW/A192KW/A256KW) - eddsa-generated (EdDSA signing with Ed25519, Ed448 curves) Changes: - Add provider-specific elliptic curve config key mapping (ecdsaEllipticCurveKey, ecdhEllipticCurveKey, eddsaEllipticCurveKey) - Add PROVIDERS_WITHOUT_ALGORITHM constant for providers that don't need algorithm - Add elliptic curve validation per provider type - Update documentation with all supported algorithms and examples - Add comprehensive integration tests for all new providers This completes full coverage of all Keycloak key provider types.
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.
Summary
Add full support for Keycloak's auto-generated key providers where Keycloak manages the key material automatically, rather than requiring imported keys.
New Provider Types
rsa-generated- Auto-generates RSA signing keys with self-signed certificatersa-enc-generated- Auto-generates RSA encryption keyshmac-generated- Auto-generates HMAC signing keysaes-generated- Auto-generates AES encryption keysecdsa-generated- Auto-generates ECDSA signing keysecdh-generated- Auto-generates ECDH key exchange keyseddsa-generated- Auto-generates EdDSA signing keysNew Algorithms
New Config Options
secret_size- For HMAC/AES providers (key size in bytes)key_size- For RSA-generated/RSA-enc-generated providers (key size in bits: 1024, 2048, 4096)elliptic_curve- For ECDSA/ECDH/EdDSA providers:Bug Fixes
KeyErrorcrash when managing default/generated realm keys that don't haveactive,enabled, oralgorithmfields in their config responseprivate_keyandcertificateoptional (only required forrsa/rsa-encimported key providers)Backward Compatibility
provider_id=rsaorprovider_id=rsa-enccontinue to work unchangedalgorithmparameter retains itsRS256default, which is valid forrsaandrsa-generatedprovidersKeycloak Source Reference
Configuration options were matched against the official Keycloak source code:
hmac-generatedalgorithm(HS256/384/512),secretSizeaes-generatedsecretSize(no algorithm - always AES)ecdsa-generatedecdsaEllipticCurveKey(P-256/384/521)ecdh-generatedecdhEllipticCurveKey(P-256/384/521)eddsa-generatededdsaEllipticCurveKey(Ed25519/Ed448)rsa-generatedalgorithm(RS/PS 256/384/512),keySizersa-enc-generatedalgorithm(RSA1_5/RSA-OAEP/RSA-OAEP-256),keySizeParameter Mapping:
elliptic_curve→ provider-specific config keys (ecdsaEllipticCurveKey,ecdhEllipticCurveKey,eddsaEllipticCurveKey)secret_size→secretSize(standard camelCase conversion)key_size→keySize(standard camelCase conversion)Test Plan
Example Usage