Skip to content

Link authentication flow UsedBy clients to client settings - #48841

Merged
edewit merged 4 commits into
keycloak:mainfrom
singhvishalkr:fix-40211-usedby-client-links
Jul 25, 2026
Merged

edewit merged 4 commits into
keycloak:mainfrom
singhvishalkr:fix-40211-usedby-client-links

Conversation

@singhvishalkr

@singhvishalkr singhvishalkr commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Closes #40211.

Problem:
The authentication flows table can show which clients override a flow, but the Admin UI only had the clientId label and could not link directly to the client settings page.

Root cause:
The existing used-by payload exposed display labels but not the internal client UUID required by the client settings route.

Solution:

  • Include client references with internal id and clientId in the flows payload for client-specific used-by hints.
  • Return neutral { id, label } rows from the paginated used-by endpoint so both client and identity-provider results have a clear contract.
  • Link client used-by rows when an internal id is available and keep identity-provider rows as plain labels.
  • Preserve pagination while searching by applying skip(first) after filtering client rows.

Verification:

  • corepack pnpm exec prettier --check apps/admin-ui/src/authentication/components/UsedBy.tsx apps/admin-ui/src/components/role-mapping/resource.ts
  • corepack pnpm --filter @keycloak/keycloak-admin-ui build
  • .\mvnw.cmd -pl rest/admin-ui-ext -am -DskipTests -DskipITs compile
  • git diff --check

@singhvishalkr
singhvishalkr requested review from a team as code owners May 8, 2026 14:48
@singhvishalkr
singhvishalkr force-pushed the fix-40211-usedby-client-links branch from 95a32b1 to 2cd8e8e Compare May 9, 2026 04:25

@edewit edewit 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.

This introduces a lot of queries, it would be better to change the endpoint to return the uuid and the clientId.

@singhvishalkr

Copy link
Copy Markdown
Contributor Author

Pushed ec66b12: ui-ext /flows now includes clientRefs (internal id + clientId) for SPECIFIC_CLIENTS, and the paginated authentication-management used-by clients response returns the same object shape so UsedBy.tsx no longer calls clients.find per row. I did not run mvn here because JAVA_HOME is not set on the agent.

@singhvishalkr

Copy link
Copy Markdown
Contributor Author

@edewit On current head the realm authentication table already gets clientRefs built in AuthenticationMapper (internal id + clientId), and GET .../authentication/{type}/{id} maps clients to UsedByClientRef(c.getId(), c.getClientId()). If you still see extra client lookups in the network panel, point at the call path you want collapsed and I will trim it. Otherwise I would treat the earlier review as addressed and need a fresh review when you have a moment.

@singhvishalkr

Copy link
Copy Markdown
Contributor Author

Visibility ping: ready to address comments whenever reviewers post them.

@singhvishalkr

Copy link
Copy Markdown
Contributor Author

HEAD ec66b12 already extends UsedBy payloads with clientRefs (realm uuid + clientId) per your 2026-05-11 note (clients.find resolution removed from UsedBy.tsx). CHANGES_REQUESTED still pins 2cd8e8e; can you dismiss or approve on ec66b12? (@edewit**)

@singhvishalkr

Copy link
Copy Markdown
Contributor Author

Typo repair: tagging @edewit explicitly for visibility on **ec66b12.

@singhvishalkr

Copy link
Copy Markdown
Contributor Author

I checked the current head and it now returns uuid and clientId without the earlier query fan-out. That matches the review request, so I am asking for another pass on the branch as it stands now.

@edewit

edewit commented May 26, 2026

Copy link
Copy Markdown
Contributor

@singhvishalkr it's got a build error:

[INFO] src/authentication/components/UsedBy.tsx(185,43): error TS2322: Type 'string | null | undefined' is not assignable to type 'string | undefined'.
[INFO]   Type 'null' is not assignable to type 'string | undefined'.
[INFO] ❌ 1 script failed.

@singhvishalkr
singhvishalkr force-pushed the fix-40211-usedby-client-links branch from ec66b12 to dbc79e4 Compare June 11, 2026 16:08
@singhvishalkr

singhvishalkr commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated the branch. The popover path now normalizes ref.id with ?? undefined before passing it to ClientUsedByLink, matching the table renderer and fixing the reported string | null | undefined prop mismatch.

@singhvishalkr

Copy link
Copy Markdown
Contributor Author

Current head already returns UsedByClientRef objects from the backend, carries clientRefs through usedBy, and uses
ef.id ?? undefined on the UI link path. That removes the client-side lookup fan-out and fixes the null typing issue in UsedBy.tsx. Happy to adjust further if there is another call path you want collapsed.

@edewit

edewit commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

@singhvishalkr there another build issue

Copilot AI review requested due to automatic review settings June 18, 2026 16:09
@singhvishalkr

Copy link
Copy Markdown
Contributor Author

Updated the branch. The Admin UI failure was Prettier on UsedBy.tsx, so I split the two ClientUsedByLink prop lists that CI flagged.

Validated with:

  • corepack pnpm exec prettier --check apps/admin-ui/src/authentication/components/UsedBy.tsx
  • git diff --check

I also tried corepack pnpm --filter @keycloak/keycloak-admin-ui lint locally, but on this Windows checkout it fails on CRLF Prettier errors across many untouched files. I left those unrelated files unchanged.

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.

Pull request overview

Adds linkable client references to the “Used by” hints for authentication flows in the Admin UI, enabling direct navigation to a client’s settings page by using the internal client UUID.

Changes:

  • Introduces a UsedByClientRef DTO and extends UsedBy to optionally include clientRefs for SPECIFIC_CLIENTS.
  • Updates backend mapping and the authentication-management/{type}/{id} endpoint to return { id, clientId } objects instead of plain strings.
  • Updates the Admin UI to render client entries as links (when an internal id is available) in both the popover and the modal.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
rest/admin-ui-ext/src/main/java/org/keycloak/admin/ui/rest/model/UsedByClientRef.java New DTO to carry internal client id + clientId label.
rest/admin-ui-ext/src/main/java/org/keycloak/admin/ui/rest/model/UsedBy.java Adds optional clientRefs field for linkable client references.
rest/admin-ui-ext/src/main/java/org/keycloak/admin/ui/rest/model/AuthenticationMapper.java Populates clientRefs for SPECIFIC_CLIENTS used-by info.
rest/admin-ui-ext/src/main/java/org/keycloak/admin/ui/rest/AuthenticationManagementResource.java Changes “list used-by” endpoint to return UsedByClientRef objects (clients + idp).
js/apps/admin-ui/src/components/role-mapping/resource.ts Updates fetchUsedBy() return type to UsedByClientRef[].
js/apps/admin-ui/src/authentication/constants.ts Extends AuthenticationType.usedBy to include optional clientRefs.
js/apps/admin-ui/src/authentication/components/UsedBy.tsx Renders linkable client entries in popover + modal using internal client id.

Comment on lines 110 to 111
.map(c -> new UsedByClientRef(c.getId(), c.getClientId())).filter(ref -> ref.getClientId().contains(search))
.skip("".equals(search) ? first : 0).limit(max).collect(Collectors.toList());
Comment on lines +114 to +116
if ("idp".equals(type)) {
return session.identityProviders().getByFlow(flow.getId(), search, first, max).toList();
return session.identityProviders().getByFlow(flow.getId(), search, first, max)
.map(alias -> new UsedByClientRef(null, alias)).collect(Collectors.toList());
Comment on lines +147 to +156
const clientRefs = usedBy?.clientRefs;
const clientsOrFallback: FlowUsedByRow[] = useMemo(() => {
if (!usedBy || usedBy.type !== "SPECIFIC_CLIENTS") {
return [];
}
if (clientRefs && clientRefs.length > 0) {
return clientRefs;
}
return usedBy.values.map((clientId) => ({ clientId }));
}, [usedBy, clientRefs]);
@singhvishalkr

Copy link
Copy Markdown
Contributor Author

Updated the branch for the latest review comments.

Changes made:

  • search pagination now applies skip(first) after filtering client rows, so page 2+ works with a search term
  • the paginated used-by endpoint now returns a neutral { id, label } row instead of using the client-specific DTO for IdP rows
  • the Admin UI maps those rows back to client links only for client results and renders IdP results as labels
  • the PR description now matches the current backend-provided reference approach

Validated with:

  • corepack pnpm exec prettier --check apps/admin-ui/src/authentication/components/UsedBy.tsx apps/admin-ui/src/components/role-mapping/resource.ts
  • corepack pnpm --filter @keycloak/keycloak-admin-ui build
  • .\mvnw.cmd -pl rest/admin-ui-ext -am -DskipTests -DskipITs compile
  • git diff --check

@singhvishalkr
singhvishalkr force-pushed the fix-40211-usedby-client-links branch from 96987c3 to bdb2294 Compare June 18, 2026 16:44
…ings

Signed-off-by: Vishal Kumar Singh <vishal.kr.singh2021@gmail.com>
…rnal ids

Extend ui-ext /flows UsedBy for SPECIFIC_CLIENTS with clientRefs (realm internal id plus clientId).
Return the same shape from paginated authentication-management used-by clients rows.
Drop clients.find resolution from UsedBy.tsx.

Signed-off-by: Vishal Kumar Singh <vishal.kr.singh2021@gmail.com>
Signed-off-by: Vishal Kumar Singh <vishal.kr.singh2021@gmail.com>
Signed-off-by: Vishal Kumar Singh <vishal.kr.singh2021@gmail.com>
@edewit
edewit enabled auto-merge (squash) July 23, 2026 08:29
Copilot AI review requested due to automatic review settings July 23, 2026 08:43
@edewit
edewit force-pushed the fix-40211-usedby-client-links branch from bdb2294 to 85fc9da Compare July 23, 2026 08:43

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@keycloak-github-bot keycloak-github-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@keycloak-github-bot

Copy link
Copy Markdown

Unreported flaky test detected

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.keycloak.testsuite.forms.BrowserFlowTest#testUserWithOneAdditionalFactorOtpSuccess

Keycloak CI - Base IT (5)

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)
...

Report flaky test

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.

Add link to clients in UsedBy hint for auth-flows listing in admin ui

4 participants