8000 Show sub-resource events in Admin events tabs by ahus1 · Pull Request #55120 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Show sub-resource events in Admin events tabs - #55120

Draft
ahus1 wants to merge 6 commits into
keycloak:mainfrom
ahus1:is-55119-admin-events-tabs-subresources
Draft

ahus1 wants to merge 6 commits into
keycloak:mainfrom
ahus1:is-55119-admin-events-tabs-subresources

Conversation

@ahus1
@ahus1 ahus1 commented Nov 12, 2026 •
Copy link
Copy Markdown
Member

Closes #55119

The "Admin events" tabs now list the events of an object and of its sub-resources, using filters that can use an index on RESOURCE_PATH (no leading wildcard).

Decisions and assumptions:

  • The backend stays unchanged and backwards compatible. AdminEvents accepts several resourcePath patterns, sends one request per pattern, and merges the results by time in the UI. Each request asks for first + max entries so that pagination stays correct.
  • Tabs use the exact path plus /* instead of a trailing *, as names, aliases and federated ids can be prefixes of each other. Where only some sub-resources record events (client roles, group role mappings), the tab lists exactly those.
  • Client roles use clients/<id>/roles/<name> and roles-by-id/<id>, as changes are recorded under both depending on the endpoint used. Client role tabs list only the composites sub-resource, as role names can contain / and a /* pattern would match other roles. Existing events can't be disambiguated further, and a role named like admin/composites still collides with the composites of admin. The client scope tab also includes the realm default scope paths and the client assignments (clients/*/default-client-scopes/<id>, which can only be narrowed by the clients/ prefix).
  • The server matches the path with SQL LIKE, so _ and % in names are wildcards as well. For paths containing them, AdminEvents drops false matches client-side and keeps reading pages until the requested page is filled. Patterns can overlap, so merged results are deduplicated by event id and ties in time are ordered by id, as the backend has no tie-breaker. Events with the same timestamp can still repeat or be skipped at a page boundary. This is accepted as a known limitation until the backend accepts several paths in one request (Allow multiple and literal resource paths when querying admin events #55126). * is kept as the wildcard in that check, so a literal * in a name is matched like the server does. A \ in a name can't be found, as the server doesn't escape it (Allow multiple and literal resource paths when querying admin events #55126).
  • Group tabs list role mappings on the main tab, as membership and child group events have their own tabs. Organization invitations are listed with the membership events, as sending an invitation is recorded there. Changes to management permissions record no event (Enabling fine-grained management permissions doesn't record an admin event #55145), so no tab lists them yet. Realm role tabs don't list events recorded by name (Realm role Admin events tab misses create event and events recorded by role name #55122).
  • The new resource-events.spec.ts uses a new realm for each test and checks the type and operation of the listed events.

Closes keycloak#55119

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The event filters omit valid role and client-scope events, can include unrelated role events, and may leave client-role Events tabs empty when opened directly.

5 open issues
What changed in this PR

Updates the Admin Console’s resource event tabs to include sub-resource activity, addressing #55119 without changing the backend API.

Changes:

  • Queries multiple resource-path patterns and merges results by time for pagination.
  • Updates resource-specific filters and removes the client-scope filter’s leading wildcard.
  • Adds isolated-realm browser tests and supporting admin-client helpers.
File Description
js/​apps/​admin-ui/​test/​utils/​AdminClient.ts Adds helpers for creating and updating test resources.
js/​apps/​admin-ui/​test/​events/​resource-events.spec.ts Tests resource event visibility and filtering.
js/​apps/​admin-ui/​src/​user/​EditUser.tsx Separates exact user paths from sub-resource patterns.
js/​apps/​admin-ui/​src/​realm-roles/​RealmRoleTabs.tsx Adds client-role name paths and role sub-resource patterns.
js/​apps/​admin-ui/​src/​organizations/​DetailOrganization.tsx Expands organization and membership event filters.
js/​apps/​admin-ui/​src/​identity-providers/​add/​DetailSettings.tsx Includes identity-provider sub-resource events.
js/​apps/​admin-ui/​src/​groups/​GroupsSection.tsx Includes role-mapping and management events.
js/​apps/​admin-ui/​src/​events/​AdminEvents.tsx Supports multiple patterns with merged, paginated results.
js/​apps/​admin-ui/​src/​clients/​ClientDetails.tsx Includes client sub-resource events.
js/​apps/​admin-ui/​src/​client-scopes/​EditClientScope.tsx Uses anchored client-scope and sub-resource patterns.

Review effort: Balanced

Closes keycloak#55119

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Audit-event queries can include another identity provider’s events and duplicate client-role events, producing incorrect audit rows and consuming pagination slots.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Alias LIKE queries match unrelated providers

js/​apps/​admin-ui/​src/​identity-providers/​add/​DetailSettings.tsx:938

Aliases may contain _, but these SQL LIKE queries lack the literal matchPath guard used for client roles. For example, corp_sso/* also returns mapper events from corp-sso; add an exact-or-subpath matcher here so another provider's events are filtered out before pagination.

5 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The changes omit client-scope assignment audit events, misattribute events for slash-containing role names, and can repeat or skip events across pages.

1 open issue
2 previously missed issues

In code that hasn't changed since last review

Medium severity Restore client-assignment paths in scope audit filters

js/​apps/​admin-ui/​src/​client-scopes/​EditClientScope.tsx:308

The old *client-scopes/${id} filter also matched client assignments recorded by ClientResource as clients/<clientId>/default-client-scopes/${id} and clients/<clientId>/optional-client-scopes/${id}; neither path matches this new list, so existing CLIENT_SCOPE_CLIENT_MAPPING CREATE/DELETE events disappear from the scope's audit tab. Include both client-assignment patterns to preserve those events without restoring a leading wildcard.

Medium severity Disambiguate audit queries for slash-containing role names

js/​apps/​admin-ui/​src/​realm-roles/​RealmRoleTabs.tsx:344

Client role names may contain /, and RoleContainerResource records CREATE paths using the raw name. With roles admin and admin/read, this pattern therefore includes admin/read's CREATE event in admin's tab; the literal-path guard cannot distinguish it from a descendant either. Narrow the name-based subresource queries to supported role endpoints and disambiguate role identity where paths collide, with a regression case for slash-containing names.

1 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The client-scope filter mishandles the intentional * wildcard, displaying assignments for scope-id when filtering for scope_id instead of treating _ and % literally.

1 open issue
1 resolved since last review

Review effort: Balanced

Closes keycloak#55119

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because the tests leave merged pagination and false-match filtering unverified, while repeated row assertions can mask missing events.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin events tabs miss events of sub-resources and client roles

2 participants

0