8000 Update password after email verification during registration of users by mposolda · Pull Request #47538 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Update password after email verification during registration of users - #47538

Merged
mposolda merged 2 commits into
keycloak:mainfrom
mposolda:45568-register-verify-email
Apr 17, 2026
Merged

mposolda merged 2 commits into
keycloak:mainfrom
mposolda:45568-register-verify-email

Conversation

@mposolda
@mposolda mposolda commented Mar 27, 2026 •
Copy link
Copy Markdown
Contributor

closes #45568

For the case when both registration and verify-email is enabled, this PR updates the behavior:

  • Registration page shown without password field first. User is able to register his profile attributes only (username, email, firstName, lastname...)
  • User required to verify email once registering his profile
  • After email verification, password setup is required as next step

Few more clarifications:

  • When the "verify email" link is opened in the new browser, then after the successful email verification in the new browser, the original authentication session in the browser1 is removed. This is for security reasons. If there are any follow-up required actions, they can be performed in the browser2 after email verification, but there is not redirection to the client application after all required actions are finished (END_AFTER_REQUIRED_ACTIONS is still set in the browser2 authentication session similarly like before). The PR does not contain removal of all user's authentication sessions after email is verified. This should be added as a follow-up to this issue.

  • For the backwards compatibility, I've added switch Always set password on register form on Password validation as maybe the new behavior is not desired for everyone and want to update issues with backwards compatibility.

@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.model.session.UserSessionProviderModelTest#testStreamsMarshalling

Keycloak CI - Store Model Tests

java.lang.AssertionError: 
threads didn't terminate in time: [main (RUNNABLE):
	at java.management@25.0.2/sun.management.ThreadImpl.dumpThreads0(Native Method)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:505)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:493)
...

Report flaky test

@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 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.model.session.UserSessionPersisterProviderTest#testUpdateAndRemove

Keycloak CI - Store Model Tests

org.infinispan.remoting.RemoteException: ISPN000217: Received exception from node-47, see cause for remote stack trace
	at org.infinispan.remoting.transport.ResponseCollectors.wrapRemoteException(ResponseCollectors.java:26)
	at org.infinispan.remoting.transport.ValidSingleResponseCollector.withException(ValidSingleResponseCollector.java:37)
	at org.infinispan.remoting.transport.ValidSingleResponseCollector.addResponse(ValidSingleResponseCollector.java:21)
	at org.infinispan.remoting.transport.impl.SingleTargetRequest.addResponse(SingleTargetRequest.java:69)
...

Report flaky test

@mposolda
mposolda force-pushed the 45568-register-verify-email branch from 3d4038a to 1975684 Compare April 16, 2026 10:27
@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.model.session.UserSessionProviderOfflineModelTest#testLoadingOfflineClientSessionWhenCreatedBeforeSessionTime

Keycloak CI - Store Model Tests

org.infinispan.remoting.RemoteException: ISPN000217: Received exception from node-75, see cause for remote stack trace
	at org.infinispan.remoting.transport.ResponseCollectors.wrapRemoteException(ResponseCollectors.java:26)
	at org.infinispan.remoting.transport.ValidSingleResponseCollector.withException(ValidSingleResponseCollector.java:37)
	at org.infinispan.remoting.transport.ValidSingleResponseCollector.addResponse(ValidSingleResponseCollector.java:21)
	at org.infinispan.remoting.transport.impl.SingleTargetRequest.addResponse(SingleTargetRequest.java:69)
...

Report flaky test

@mposolda
mposolda requested a review from rmartinc April 16, 2026 13:09
@rmartinc rmartinc 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.

Thanks a lot for this @mposolda! LGTM in general. I have just three comments. Two of them are easy and the other is a bit harder now you have everything setup (the change for verify email priority instead of the OTP and password). I prefer to have verify email with the highest priority but, if you think that it's a lot of work, the current order is OK because only Terms&Conditions and Verify Profile are higher.

@@ -156,7 +156,7 @@ public static void addConfigureTotpAction(RealmModel realm) {
totp.setName("Configure OTP");
totp.setProviderId(UserModel.RequiredAction.CONFIGURE_TOTP.name());
totp.setDefaultAction(false);
totp.setPriority(10);
totp.setPriority(54);
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.

Marek, would not be better to move the verify email action to the priority 1 (always the first to be presented). This way all the required actions are always after the verify email. It's only terms&Conditions and Update Profile with this change, so maybe it's enough. But I think that, if verify email is the first one, no action is never done at the registration side, everything is done at the verification email side.

Sorry for not thinking about this before.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For this one, it seems to me that "Verify email" should be done after "Update profile" ?

Thinking that when user has both Update profile and Verify email required actions, it would makes sense that he first updates his profile and then email is verified as a subsequent step (as email was possibly updated by user during updating profile). That is also aligned with registration form (User in fact first registers, which pretty much updating his profile info and then email verification is a next step and then possibly password-update or other credentials update are another subsequent step). WDYT?

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.

Yes, as I commented the current PR order is OK. Verify email should be before any credential action, and that's OK now. About the update profile I didn't check that exact scenario, I just preferred the verify email to be first, but maybe you are right and update profile should be before verify email.

String alwaysSetPasswordCfg = context.getAuthenticatorConfig() == null ? null : context.getAuthenticatorConfig().getConfig().get(ALWAYS_SET_PASSWORD_ON_REGISTER_FORM);
if ("true".equals(alwaysSetPasswordCfg)) return false;

return context.getRealm().isVerifyEmail();
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.

Probably we should also check if the required action for verify_email is set as default true. Just in case the verify email is enabled using that option instead of the realm.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated, Thanks for the suggestion! Added automated test for this - introduced RegisterWithEmailVerificationTest and added to the new testsuite (with some more RegisterTest related to email verification moved).

BD0

If you still prefer to keep password on the initial registration form and make email verification to be done once user self-registers with his password, you can
setup the configuration option on the <<_authentication-flows,Registration authentication flow>>. It can be done in the admin console by following tab *Authentication* ->
flow *registration* (or other flow, which you bind as registration flow) -> Settings of *Password validation* -> Enable *Always set password on register form*
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.

Maybe mention that this option is deprecated and probably removed in a future version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated, Thanks for the suggestion!

@mposolda
mposolda force-pushed the 45568-register-verify-email branch from f84dc0b to 6b65c9e Compare April 17, 2026 10:23
@rmartinc rmartinc 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.

Thanks @mposolda! LGTM if the tests run OK. Check if the failed test is related.

…l to the new testsuite

Signed-off-by: mposolda <mposolda@gmail.com>
@mposolda
mposolda force-pushed the 45568-register-verify-email branch from 6b65c9e to 5b9eb6f Compare April 17, 2026 10:56
@mposolda
mposolda enabled auto-merge (squash) April 17, 2026 13:13
@mposolda
mposolda disabled auto-merge April 17, 2026 13:15
@mposolda
mposolda merged commit 72e0c26 into keycloak:main Apr 17, 2026
88 of 91 checks passed
@stianst stianst mentioned this pull request Jun 1, 2026
sashyo pushed a commit to tide-foundation/keycloak-IGA that referenced this pull request Jul 20, 2026
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.

Pending auth flow waiting for email verification succeeds even after password reset - providing room for pre-account takeover attacks

2 participants

0