Handle orphan authenticator providers in flows - #48372
Conversation
0dca0fc to
7125f1e
Compare
|
Quick question for maintainers on the copyright header of the new test file I removed the
What's your preference?
Happy to push whichever you prefer. |
7125f1e to
aa83bbd
Compare
Unreported flaky test detectedIf 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.saml.SamlClientTest#testLoginWithOIDCClientKeycloak CI - Java Distribution IT (windows-latest - temurin - 21) org.keycloak.testsuite.saml.SamlClientTest#testLoginWithOIDCClientKeycloak CI - Java Distribution IT (windows-latest - temurin - 17) org.keycloak.testsuite.saml.SamlClientTest#testLoginWithOIDCClientKeycloak CI - Java Distribution IT (ubuntu-latest - temurin - 17) org.keycloak.testsuite.saml.SamlClientTest#testLoginWithOIDCClientKeycloak CI - Java Distribution IT (ubuntu-latest - temurin - 21) org.keycloak.testsuite.adapter.servlet.SAMLServletAdapterTest#testSavedPostRequestKeycloak CI - Adapter IT Strict Cookies |
aa83bbd to
a4f55e2
Compare
There was a problem hiding this comment.
Pull request overview
This PR makes authentication flow management resilient to “orphan” executions—executions that reference an authenticator provider ID whose factory is no longer registered—so the Admin UI and Admin REST API can still list, reorder (within the same flow), and delete those executions instead of failing with a 404.
Changes:
- Admin REST: return a placeholder execution representation (including a new
providerUnavailableflag) instead of throwingNotFoundExceptionwhen the authenticator factory is missing. - Admin UI: surface a “Provider unavailable” indicator and prevent operations that would implicitly re-create the execution in a different flow (cross-flow move) or edit configuration.
- Tests & client types: add an integration test covering listing/removal and extend the admin-client TS type with
providerUnavailable.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
tests/base/src/test/java/org/keycloak/tests/admin/authentication/OrphanExecutionTest.java |
Adds coverage ensuring orphan executions are still listed and can be removed via admin API. |
services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java |
Stops throwing on missing authenticator factory during execution listing; emits a placeholder rep and sets providerUnavailable. |
core/src/main/java/org/keycloak/representations/idm/AuthenticationExecutionInfoRepresentation.java |
Adds providerUnavailable to the execution info representation. |
js/libs/keycloak-admin-client/src/defs/authenticationExecutionInfoRepresentation.ts |
Extends the TS definition to include providerUnavailable?: boolean. |
js/apps/admin-ui/src/authentication/FlowDetails.tsx |
Blocks cross-flow move for orphan-containing nodes (to avoid delete + re-create losing rows) and makes child moves sequential. |
js/apps/admin-ui/src/authentication/components/FlowTitle.tsx |
Displays a warning label and help text when providerUnavailable is true. |
js/apps/admin-ui/src/authentication/components/FlowRow.tsx |
Hides the execution config modal trigger for orphan executions. |
js/apps/admin-ui/maven-resources/theme/keycloak.v2/admin/messages/messages_en.properties |
Adds i18n strings for the “provider unavailable” UI messaging. |
a4f55e2 to
5457349
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java:763
providerIdis Base32-encoded unconditionally forscript-providers, even whenfactory == null(orphan execution). That breaks the stated goal of preserving the original provider id for orphaned executions, and can make the orphan fallback inconsistent (displayNameis set from the raw id earlier, butproviderIdbecomes encoded here). Consider only encoding when a factory is present (i.e., the provider is actually available) and keep the raw value for orphan placeholders.
// encode the provider id in case the provider is a script deployed to the server to make sure it can be used as path parameters without break the URL syntax
if (providerId.startsWith("script-")) {
providerId = Base32.encode(providerId.getBytes());
}
The admin REST endpoint that lists flow executions threw NotFoundException when an execution referenced a provider id with no registered factory (SPI uninstalled/renamed/failed to register). The Admin UI propagated the 404 to its global error boundary, making the whole flow page uneditable — the admin could not delete the orphan execution or manage the rest of the flow. Backend: populate a placeholder AuthenticationExecutionInfoRepresentation with providerUnavailable=true when the factory lookup returns null, so listing keeps working. AuthenticationExecutionInfoRepresentation gains an optional providerUnavailable Boolean. Admin UI: FlowTitle shows a red "Provider unavailable" badge, FlowRow hides the gear icon, and cross-flow drag is rejected up-front (including when an orphan is nested inside a sub-flow being moved) so the delete + re-create sequence never silently drops the row. Same-flow reorder and delete remain functional. Closes keycloak#15535 Signed-off-by: erenkan <eren@keymate.io>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Eren Kan <erenkn@gmail.com>
750b456 to
a4c5975
Compare
Closes #15535
Problem
An authentication flow execution stores only its provider id string. If the referenced SPI is uninstalled, renamed, or fails to register,
GET /admin/realms/{realm}/authentication/flows/{alias}/executionsthrowsNotFoundException("Could not find authenticator provider"). The 404 propagates to the Admin UI's global error boundary and the entire flow page crashes — admins cannot delete the orphan execution, reorder siblings, or edit anything else in the flow.Screen.Recording.2026-04-22.at.17.22.08.mov