Repository navigation
Prevent client secrets from being reassigned on every run - #369
Merged
Merged
Conversation
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 noticed that I was getting
Notice: /Stage[main]/…/Keycloak_client[name]/secret: created secret (corrective)log messages on every run.
After some investigation, the root cause seems to be that any client that has a
namekey is treated as a built-in client:...which means that if a client has a
name, its secret isn't fetched, and the module correctively recreates the secret on every run. Note that it's possible for a client to wind up with a name even if that wasn't intended -- the module creates clients with name = nil, but opening the client in the admin UI and saving an unrelated change will convert that to name = ''.Unfortunately, AFAICT there isn't a perfect programmatic way to tell if a client is built-in. This uses a heuristic: known keycloak builtin client ids (account, account-console, admin-cli, broker, realm-management, security-admin-console) with a ${client_…} placeholder display name, and realm management clients ("realmname-realm" clientId with "realmname Realm" name). If you have any better ideas for how to do this, happy to hear them! It doesn't have to be perfect, though; false negatives just result in an extra kcadm call, and false positives result in the current behavior of an extra secret reset on each run.
Unparsable output from the client-secret endpoint also now logs a warning.
Added test cases, which fail on master and pass with this fix.