Repository navigation
Update password after email verification during registration of users #47538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+30 KB
...erver_admin/images/registration-always-set-password-on-register-form-config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
docs/documentation/upgrading/topics/changes/changes-26_7_0.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // ------------------------ Breaking changes ------------------------ // | ||
| == Breaking changes | ||
|
|
||
| Breaking changes are identified as those that might require changes for existing users to their configurations or applications. | ||
| In minor or patch releases, {project_name} will only introduce breaking changes to fix bugs. | ||
|
|
||
| // ------------------------ Notable changes ------------------------ // | ||
| == Notable changes | ||
|
|
||
| Notable changes may include internal behavior changes that prevent common misconfigurations, bugs that are fixed, or changes to simplify running {project_name}. | ||
| It also lists significant changes to internal APIs. | ||
|
|
||
| === Verify email required before credentials setup during user self-registration | ||
|
|
||
| When user self-registration is enabled for the realm together with *Verify Email*, then users will not see password by default | ||
| on the registration screen. After registration of user's profile, user would be required to verify email and then he can setup password | ||
| (or eventually other credentials like OTP or Passkey) as a subsequent step. It is possible to disable and stick to the old behavior by | ||
| enable switch *Always set password on register form* on the realm registration flow on the *Password validation* authenticator. Note | ||
| that this option is deprecated and exists mostly for the backwards compatibility. It may be removed in the future. | ||
|
|
||
| For the details, see the link:{adminguide_link}[{adminguide_name}]. | ||
|
|
||
| === Configure TOTP and Update password required actions moved after Verify Email | ||
|
|
||
| In relation to the previous point, the required actions *Configure OTP* and *Update password* are moved in the order of required actions after *Verify Email* | ||
| required action. This is done automatically for new realm or during server update. If you prefer the old order, you can manually move required actions per your preference. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
model/storage-private/src/main/java/org/keycloak/migration/migrators/MigrateTo26_7_0.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| package org.keycloak.migration.migrators; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import org.keycloak.migration.ModelVersion; | ||
| import org.keycloak.models.KeycloakSession; | ||
| import org.keycloak.models.RealmModel; | ||
| import org.keycloak.models.RequiredActionProviderModel; | ||
| import org.keycloak.models.UserModel; | ||
|
|
||
| public class MigrateTo26_7_0 extends RealmMigration { | ||
|
|
||
| public static final ModelVersion VERSION = new ModelVersion("26.7.0"); | ||
|
|
||
| @Override | ||
| public ModelVersion getVersion() { | ||
| return VERSION; | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| public void migrateRealm(KeycloakSession session, RealmModel realm) { | ||
| Map<String, RequiredActionProviderModel> reqActionsByAlias = new HashMap<>(); | ||
| List<Integer> reqActionPriorities = new ArrayList<>(); | ||
| realm.getRequiredActionProvidersStream().forEach((reqAction) -> { | ||
| reqActionsByAlias.put(reqAction.getAlias(), reqAction); | ||
| reqActionPriorities.add(reqAction.getPriority()); | ||
| }); | ||
|
|
||
| RequiredActionProviderModel verifyEmail = reqActionsByAlias.get(UserModel.RequiredAction.VERIFY_EMAIL.name()); | ||
| RequiredActionProviderModel configureTotp = reqActionsByAlias.get(UserModel.RequiredAction.CONFIGURE_TOTP.name()); | ||
| RequiredActionProviderModel updatePassword = reqActionsByAlias.get(UserModel.RequiredAction.UPDATE_PASSWORD.name()); | ||
|
|
||
| if (verifyEmail == null) { | ||
| return; | ||
| } | ||
|
|
||
| // Default case when admin did not changed anything. Set priorities same way like in DefaultRequiredActions | ||
| if (configureTotp != null && updatePassword != null && | ||
| verifyEmail.getPriority() == 50 && configureTotp.getPriority() == 10 && updatePassword.getPriority() == 30) { | ||
| configureTotp.setPriority(54); | ||
| realm.updateRequiredActionProvider(configureTotp); | ||
| updatePassword.setPriority(57); | ||
| realm.updateRequiredActionProvider(updatePassword); | ||
| } else { | ||
| // Case when admin changed priorities of required actions. Add configureTotp and updatePassword to the first free places after verifyEmail | ||
| int nextAvailablePriority = getFirstAvailablePriorityAfter(verifyEmail.getPriority(), reqActionPriorities); | ||
| if (configureTotp != null) { | ||
| configureTotp.setPriority(nextAvailablePriority); | ||
| realm.updateRequiredActionProvider(configureTotp); | ||
| nextAvailablePriority = getFirstAvailablePriorityAfter(nextAvailablePriority, reqActionPriorities); | ||
| } | ||
| if (updatePassword != null) { | ||
| updatePassword.setPriority(nextAvailablePriority); | ||
| realm.updateRequiredActionProvider(updatePassword); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private int getFirstAvailablePriorityAfter(int priority, List<Integer> reqActionPriorities) { | ||
| for (int i = priority + 1 ; i < (priority + reqActionPriorities.size() + 2) ; i++) { | ||
| if (!reqActionPriorities.contains(i)) { | ||
| return i; | ||
| } | ||
| } | ||
|
|
||
| // Should not happen | ||
| return reqActionPriorities.get(reqActionPriorities.size() - 1) + 1; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 profileandVerify emailrequired 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?There was a problem hiding this comment.
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.