You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for more update attribute user events - #51017
RESET_PASSWORD represents the password-reset flow, not a completed credential update; the actual update path emits UPDATE_CREDENTIAL. Including it here can run update-credential workflows when a reset is merely initiated.
The admin credential-removal endpoint emits OperationType.ACTION, so this condition classifies a removal as an update. Require the update operation explicitly to keep user-update-credential from firing on removals.
The actual admin removal endpoint records this operation as ACTION (services/.../UserResource.java:890), so admin credential removals never activate this provider. Match the operation emitted by that endpoint.
if (!OperationType.DELETE.equals(adminEvent.getOperationType())) {
A non-null email only means the submitted user representation contains an email, not that it changed. Admin clients commonly submit full representations, so unrelated user updates will incorrectly activate user-update-email; the producer/provider contract needs actual before/after change data.
This checks whether the requested attribute was present in the admin representation, not whether it was updated. A full user representation therefore activates filtered profile workflows for unchanged attributes, contrary to the attribute-update filter contract.
user-update-consent also fires for GRANT_CONSENT, although issue #50453 requests the distinct Update consent event. A new consent grant should not execute workflows configured for updates.
The only matching admin mutation is consent revocation (UserResource.java:644-666), so this makes a user-update-consent workflow run for a revoke rather than an update. Do not claim these admin events unless a genuine admin consent-update operation is available.
RESET_PASSWORD is a distinct event used by the forgot-credentials flow, not the requested UPDATE_CREDENTIAL event, so this activates the workflow for password-reset events that are not credential updates. Restrict user events to UPDATE_CREDENTIAL; the test must emit that event with Details.CREDENTIAL_TYPE=password.
The admin credential-removal endpoint uses this exact path with OperationType.ACTION (UserResource.java:871-894), so the !DELETE check classifies removals as credential updates. Only accept an actual UPDATE operation for this branch.
Admin credential removal is emitted as OperationType.ACTION, not DELETE (UserResource.java:890), so real admin removals never reach this workflow provider. Match the operation used by that endpoint.
if (!OperationType.DELETE.equals(adminEvent.getOperationType())) {
return false;
GRANT_CONSENT is a separate event for creating consent, while this trigger is specifically for the requested UPDATE_CONSENT event. Including it causes user-update-consent workflows to run on initial grants as well as updates.
Presence of email in an admin PUT representation does not mean the email changed; clients commonly submit a full UserRepresentation, so an unrelated profile update will activate user-update-email. Record or compare the old email when handling the admin update and filter on an actual change.
An admin event representation contains submitted values, not the set of changed attributes. With a normal full user PUT, non-null firstName/email fields make these filters match even when only another attribute changed; capture changed-field details before the update and evaluate those instead.
if ("email".equalsIgnoreCase(configParameter)) {
return rep.getEmail() != null;
} else if ("firstName".equalsIgnoreCase(configParameter) || "first_name".equalsIgnoreCase(configParameter)) {
return rep.getFirstName() != null;
} else if ("lastName".equalsIgnoreCase(configParameter) || "last_name".equalsIgnoreCase(configParameter)) {
If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.
org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
...
This admin-event matcher classifies consent revocation as user-update-consent: the only matching admin endpoint is DELETE users/{id}/consents/{client}, which emits ACTION, while the equivalent account operation emits REVOKE_GRANT. Restrict this provider to actual consent updates (or omit admin support until such an operation exists).
evaluate() contains logic for EventType.RESET_PASSWORD, but supports(Event) only returns true for UPDATE_CREDENTIAL, making the RESET_PASSWORD branch unreachable for end-user events. If the intent is for user-update-credential to also trigger for password resets, update supports(Event) (and potentially create(Event) if applicable) to include RESET_PASSWORD.
public boolean supports(Event event) {
return EventType.UPDATE_CREDENTIAL.equals(event.getType());
}
evaluate() contains logic for EventType.RESET_PASSWORD, but supports(Event) only returns true for UPDATE_CREDENTIAL, making the RESET_PASSWORD branch unreachable for end-user events. If the intent is for user-update-credential to also trigger for password resets, update supports(Event) (and potentially create(Event) if applicable) to include RESET_PASSWORD.
if (originalEvent instanceof Event event) {
if (EventType.RESET_PASSWORD.equals(event.getType())) {
credentialType = "password";
} else if (event.getDetails() != null) {
credentialType = event.getDetails().get(Details.CREDENTIAL_TYPE);
}
} else if (originalEvent instanceof AdminEvent adminEvent) {
When configParameter is blank, evaluate() returns true for admin user UPDATE events, even if no profile-related fields changed (e.g., toggling enabled, required actions, etc.). This makes user-update-profile potentially trigger on any admin user update. Consider requiring that at least one profile-related updated_* detail key is present in the underlying event details when the trigger has no parameter, so the trigger more closely matches its name/intent.
if (configParameter == null || configParameter.isBlank()) {
return true;
}
When configParameter is blank, evaluate() returns true for admin user UPDATE events, even if no profile-related fields changed (e.g., toggling enabled, required actions, etc.). This makes user-update-profile potentially trigger on any admin user update. Consider requiring that at least one profile-related updated_* detail key is present in the underlying event details when the trigger has no parameter, so the trigger more closely matches its name/intent.
} else if (originalEvent instanceof AdminEvent adminEvent) {
if (adminEvent.getDetails() == null) {
return false;
}
Building admin event detail keys from arbitrary attribute keys can collide with reserved/known keys (e.g. an attribute named first_name results in updated_first_name, potentially overwriting the explicit first-name detail). To avoid collisions and make consumers more robust, consider using a dedicated namespace/prefix for user attributes (e.g. updated_attr_<key>) or explicitly skipping/escaping keys that would conflict with existing detail keys.
Unlike the other admin-event providers added here, this supports(AdminEvent) does not constrain OperationType. Adding an operation-type filter (e.g. only operations that actually modify consents) would reduce the chance of triggering workflows on non-mutating consent-related admin events and keep provider behavior consistent across the new triggers.
@Override
public boolean supports(AdminEvent adminEvent) {
if (!org.keycloak.events.admin.ResourceType.USER.equals(adminEvent.getResourceType())) {
return false;
}
String path = adminEvent.getResourcePath();
if (path == null) {
return false;
}
return CONSENTS_PATH.matcher(path).matches();
}
These five new public workflow event functions are not added to the exhaustive event-function table in docs/documentation/server_admin/topics/workflows/listening-workflow-events.adoc:47-56. Users therefore cannot discover the trigger names or their optional credential-type/profile-attribute parameters; update that table as part of this API addition.
If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.
org.openqa.selenium.WebDriverException:
unknown error: unhandled inspector error: {"code":-32000,"message":"Node with given id does not belong to the document"}
(Session info: chrome=151.0.7922.137)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4'
...
Use the user profile attribute change listener to add attribute change
details to admin user update events, so that only attributes that
actually changed are reported, with the same details as user events.
Remove admin event handling that no admin endpoint emits, drop admin
support from the consent trigger, document the new event functions and
check workflow activations after the session is committed in tests.
Closeskeycloak#50453
Signed-off-by: ksushant881 <ksushant881@gmail.com>
Record the types of the credentials set when updating a user through the
admin API, so that user-update-credential workflows also trigger when a
password is set that way. Accept the previous value details in the
user-update-email and user-update-profile triggers, as only those are
set when an attribute is cleared or removed. Check activated and not
activated workflows against the same collected events in tests.
Closeskeycloak#50453
Signed-off-by: ksushant881 <ksushant881@gmail.com>
Email changes through AccountRestService.updateAccount emit only UPDATE_PROFILE with email-change details, so user-update-email never triggers for that supported account-update path. Also accept profile events containing PREVIOUS_EMAIL or UPDATED_EMAIL, while excluding unrelated profile updates.
Match built-in attribute names exactly in profile filters
Attribute names are case-sensitive, so a valid custom attribute such as Email is audited as updated_Email/previous_Email, but this case-insensitive comparison makes user-update-profile(Email) inspect the built-in email keys instead. Use exact matching for the built-in names, as the auditing listeners do, so these filters neither miss custom-attribute changes nor activate for unrelated built-in changes.
Legacy OTP credential representations are converted from the totp and
hotp types to otp when they are set, so read the credential types for
the admin event after setting the credentials, while still skipping
the credentials that were already stored.
Closeskeycloak#50453
Signed-off-by: ksushant881 <ksushant881@gmail.com>
Email changes through AccountRestService.updateAccount emit UPDATE_PROFILE with email-change details, not UPDATE_EMAIL, so user-update-email never activates for those changes. Also accept UPDATE_PROFILE events carrying previous/updated email details and add coverage through the account endpoint.
Initial consent grants emit GRANT_CONSENT (AccountRestService.upsert), but the new provider only accepts UPDATE_CONSENT, so granting a client access does not trigger this workflow. Limit the description to updates to existing consent rather than promising notifications for grants.
Trigger user-update-email workflows on UPDATE_PROFILE events that carry
email change details, as the email is updated along with the profile
when the update email action is disabled. Only trigger
user-update-profile workflows on admin user updates that changed a
profile attribute, so that credential-only or enabled-only updates do
not activate them.
Closeskeycloak#50453
Signed-off-by: ksushant881 <ksushant881@gmail.com>
The admin removal endpoint explicitly treats a null credential type as a password, but AdminEventBuilder omits that null detail, so a successful legacy-password removal never matches user-remove-credential(password). Apply the same password fallback for these admin removal events before filtering.
Avoid recording unsupported credentials as successful writes
createCredentials() ignores the null result returned by createCredentialThroughProvider() for unsupported credential types, so these representations are not necessarily applied. Recording their requested types here can activate user-update-credential workflows even though no credential changed; record only successful writes or reject unsupported 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
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.
Closes #50453