Repository navigation
fix(identity): clean up keycloak rotation state when rotation is disabled - #874
Merged
Merged
Conversation
…bled Adding the disable-secret-rotation annotation to an existing Client had no effect in Keycloak. A client PUT only updates the attributes it contains, so dropping the controlplane.secret-rotation attribute kept it set and the rotation policy kept applying. The executor-managed expiration attribute also stayed, so Keycloak still expired the secret while the status no longer reported an expiry. On opt-out, send empty values for the opt-in attribute and the rotation state attributes so Keycloak removes them, treat leftover rotation state as drift, and remove the stale SecretRotation condition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lukas016
approved these changes
Nov 19, 2026
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.
What
Adding
identity.cp.ei.telekom.de/disable-secret-rotation: "true"to an existing identityClientnow actually opts it out of secret rotation in Keycloak.Why
Opting out only worked for new clients. For a client that had already taken part in rotation:
controlplane.secret-rotationfrom the client PUT body. But a Keycloak client PUT only updates the attributes it contains, and it removes an attribute only when the value is empty. The flag stayedtrue, so the rotation policy kept applying.client.secret.expiration.timeon every client authentication, whether or not a policy applies. Meanwhile our status clearedSecretExpiresAt, so the Application lost its expiry date and expiry notifications would never fire.SecretRotationcondition was left stale (RotatedorAccepted).Changes
identity/pkg/keycloak/util/client.go""forcontrolplane.secret-rotationand the rotation attributes Keycloak manages (client.secret.expiration.time,client.secret.remaining.expiration.time,client.secret.rotated*). Keycloak removes attributes with empty values.graceful_secrets.goreuses them.identity/internal/handler/client/handler.go: removes theSecretRotationcondition when rotation isn't supported.admin-journey/features/secret-rotation.mdandarchitecture/identity.mdxnow describe opting out an existing client and opting back in.Reviewer notes
removeClientSecretRotationInfo) and the Application handler, which already assumes opt-out replaces the old secret immediately. It also avoids a valid credential that the status doesn't show.client.secret.creation.timeis kept.secretRotationfrom a Realm has a similar leftover-expiry problem. I kept this PR to the annotation; the Realm case could be a follow-up.Verification
make testandmake lintpass inidentity.