Repository navigation
Emit credential_id on UPDATE_CREDENTIAL events from built-in required actions #50787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| = Security and Standards | ||
|
|
||
| == Credential ID in credential update events | ||
|
|
||
| The `UPDATE_CREDENTIAL` events emitted by built-in required actions now carry the `credential_id` detail when a credential was created or updated in the {project_name} credential store, as the `REMOVE_CREDENTIAL` event already did. The detail is omitted when an external user-storage provider handles the update because there is no {project_name} credential ID to report. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,4 +50,13 @@ public interface CredentialInputUpdater { | |
| default Stream<CredentialModel> getCredentials(RealmModel realm, UserModel user) { | ||
| return Stream.empty(); | ||
| } | ||
|
|
||
| /** | ||
| * Updates a credential of the user with the given input, reporting the credential written to the Keycloak | ||
| * credential store. The default implementation delegates to | ||
| * {@link #updateCredential(RealmModel, UserModel, CredentialInput)} and reports no credential. | ||
| */ | ||
| default CredentialUpdate updateCredentialAndGet(RealmModel realm, UserModel user, CredentialInput input) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use also the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the CredentialUpdate record is useful here. We need to distinguish whether an update took the input and whether this update actually produced a credential. The scenarios are
If an Optional is used, both are Optional.empty(), and the UserCredentialManager cannot decide whether to move to the next provider for the update. |
||
| return new CredentialUpdate(updateCredential(realm, user, input), null); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package org.keycloak.credential; | ||
|
|
||
| /** | ||
| * The outcome of a credential update performed by a {@link CredentialInputUpdater}. | ||
| * | ||
| * @param handled whether the updater handled the input | ||
| * @param storedCredential the credential written to the Keycloak credential store, or {@code null} if the updater | ||
| * wrote it elsewhere or has no data about it | ||
| */ | ||
| public record CredentialUpdate(boolean handled, CredentialModel storedCredential) { | ||
|
|
||
| public static final CredentialUpdate NOT_HANDLED = new CredentialUpdate(false, null); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.