+
Skip to content

Disable email verification when email manually changed by idp review. #40520

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 1 commit into from
Jun 25, 2025

Conversation

rmartinc
Copy link
Contributor

@rmartinc rmartinc commented Jun 16, 2025

Add option to hide the idp review button.
Closes #40446

Draft PR that just adds the ideas presented in the issue comment.

  1. The Verify existing account by Email steps is not executed when the username or the email are modified in the Review Profile step. This way sending emails to random users is disabled. The PR sets a configuration option to revert to previous behavior (if you think that is not needed just let me know). When disabled only the re-authentication execution is available to link the account.
  2. The PR also adds an option to remove the review profile button in Confirm link existing account. I managed the option to just check if the Review Profile step was executed before. But I preferred to add the option just in case a custom review execution is used or similar. (The same, if you think that is better not to use an option and just check if the review step has been executed just let me know.)

I have chatted a bit with @pedroigor and he thinks we will need to improve email texts too. It's a good idea. We will need an upgrading note too. But I'll do both points if the general idea in this PR is OK.

Tests added. @keycloak/core-iam take a look.

Copy link

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

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

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.cluster.RealmInvalidationClusterTest#crudWithFailover

Keycloak CI - Store IT (mysql)

java.lang.RuntimeException: java.lang.IllegalStateException: Keycloak unexpectedly died :(
	at org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer.start(KeycloakQuarkusServerDeployableContainer.java:71)
	at org.jboss.arquillian.container.impl.ContainerImpl.start(ContainerImpl.java:185)
	at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$8.perform(ContainerLifecycleController.java:137)
	at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$8.perform(ContainerLifecycleController.java:133)
...

Report flaky test

@sguilhen
Copy link
Contributor

This gets a +1 from me. I am personally not sure about the option to revert to the current behavior in point 1 above. I would rather always have the username AND email change validations always in place.

@rmartinc
Copy link
Contributor Author

Thanks @sguilhen! Yes, I'm not sure either about adding the previous behavior. I just did it because maybe somebody is using only email to link users, and this way they can revert to previous behavior. Let's wait for @pedroigor and we have three votes.

@pedroigor
Copy link
Contributor

pedroigor commented Jun 19, 2025

It makes more sense to remove both new options. As @rmartinc mentioned, in a scenario where a legitimate user is trying to link an account from an IdP where the email/username is different, it is still possible to finish the linking by re-authenticating. And this mechanism is much better/secure than allowing sending arbitrary e-mails and eventually taking over accounts.

Perhaps the last thing to add is a release and upgrade guide note about this new behavior.

FTR, this is also related to #25575. Ideally, we should control the behavior of user attributes through user profile. Preventing users from changing emails when being federated from an IdP is a valid use case and could also help as an extra security layer to prevent such issues.

But regardless, we need to prevent sending verification emails when username/email changes in favor of using the user credentials.

Closes keycloak#40446

Signed-off-by: rmartinc <rmartinc@redhat.com>
@rmartinc
Copy link
Contributor Author

rmartinc commented Jun 20, 2025

OK, I have done the changes we have been talking about:

  • There is no new options for the authenticators. The email validator never sends emails if the email/username is changed during review (so previous wrong behavior is not allowed anymore). This step is only available when the username/email received from IdP is used.
  • The review button is not displayed if the idp review authenticator was not successfully executed. This avoids the option too.
  • The emails and the confirming page of the email verification have been changed a bit. IMHO the email was quite good and just added a sentence saying if you didn't initiate this process... The confirming page was modified more to differentiate title and body, and adding a message similar to the email for the body.
  • A upgrading note was added as a notable change commenting the changes.

Let's see the tests but they worked OK for me in another branch.

@mposolda
Copy link
Contributor

@rmartinc @pedroigor @sguilhen Thanks for this PR and for reviewing it!

@mposolda mposolda self-assigned this Jun 25, 2025
@mposolda mposolda merged commit 86f0a78 into keycloak:main Jun 25, 2025
76 checks passed
@slaskawi
Copy link
Contributor

Fantastic news! Thanks a million for creating the PR and reviewing it folks!

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.

Review Profile makes users prone to phishing attacks
5 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载