Skip to content

Add missing 2FA executions to built-in flows of upgraded realms - #55433

Open
jwklijnsma wants to merge 1 commit into
keycloak:mainfrom
jwklijnsma:issue-45351-migrate-2fa-flows
Open

jwklijnsma wants to merge 1 commit into
keycloak:mainfrom
jwklijnsma:issue-45351-migrate-2fa-flows

Conversation

@jwklijnsma

Copy link
Copy Markdown

Realms created before 26.3 have a conditional 2FA sub-flow in the built-in browser and first broker login flows without the conditional credential, WebAuthn and recovery codes executions. As built-in flows are read-only, administrators could not add them. The 27.0.0 migration now adds the missing executions as DISABLED so the authentication behavior does not change but administrators can enable them.

Closes #45351

Realms created before 26.3 have a conditional 2FA sub-flow in the
built-in browser and first broker login flows without the conditional
credential, WebAuthn and recovery codes executions. As built-in flows
are read-only, administrators could not add them. The 27.0.0 migration
now adds the missing executions as DISABLED so the authentication
behavior does not change but administrators can enable them.

Closes keycloak#45351

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SZrFpkHAAfJC4ohrYgzQGm
Signed-off-by: Claude <noreply@anthropic.com>
@jwklijnsma
jwklijnsma requested a review from a team as a code owner November 21, 2026 12:50
Copilot AI balanced review requested due to automatic review settings November 21, 2026 12:50

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 filter removes all executions returned by deepFindAuthenticationExecutions, preventing both built-in flows from receiving the missing 2FA executions during upgrade or import.

1 open issue
What changed in this PR

This PR addresses #45351 by extending the 27.0.0 realm migration to add missing two-factor authentication executions to older built-in browser and first broker login flows, intended to preserve existing authentication behavior.

Changes:

  • Adds migration logic for missing credential-condition, WebAuthn, and recovery-code executions as disabled.
  • Adds assertions for execution presence, disabled status, and unchanged OTP requirements.
  • Documents the migration and how administrators can enable the new options.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​migration/​AbstractMigrationTest.java Adds migration assertions for both built-in flows.
server-spi-private/​src/​main/​java/​org/​keycloak/​models/​utils/​DefaultAuthenticationFlows.java Adds a helper to populate missing disabled 2FA executions.
model/​storage-private/​src/​main/​java/​org/​keycloak/​migration/​migrators/​MigrateTo27_0_0.java Calls the helper during realm upgrades and imports.
docs/​documentation/​upgrading/​topics/​changes/​changes-27_0_0.adoc Explains the flow updates and enablement steps.

Review effort: Balanced

Comment on lines +774 to +775
.filter(AuthenticationExecutionModel::isAuthenticatorFlow)
.map(e -> realm.getAuthenticationFlowById(e.getFlowId()))
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.

Built-in authentication flows are not updated

3 participants