Skip to content
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

Registration flow fixed #19556

Conversation

vilmosnagy
Copy link
Contributor

@vilmosnagy vilmosnagy commented Apr 5, 2023

Closes #21514

Hi,

I've reported a bug in #17644. #19488 should have resolved it, but it seems to fail anyhow.

See my comment here: #19488 (comment)

@mposolda @hmlnarik I think we should implement a similar solution in the reset password flow to the idp linking flow's solution. As far as I remember in the IDP Linking flow the attributes of the newly created user is stored in an AuthNote - would you mind a solution, where:

  • instead of the setUser call in ResetCredentialChooseUser:119 we store the user's ID (?) in an auth note
    • we should refactor some of the ResetCredentialChooseUser::authenticate because of this change
  • in the ResetCredentialEmail we should use the previously stored AuthNote instead of the getUser method

What do you think about my suggestion? If I'd implement such changes in this PR would you merge it?

Regards,

@vilmosnagy vilmosnagy requested review from a team as code owners April 5, 2023 15:11
@vilmosnagy vilmosnagy requested a review from a team April 5, 2023 15:11
@vilmosnagy vilmosnagy requested a review from a team as a code owner April 5, 2023 15:11
@vilmosnagy vilmosnagy force-pushed the error-transaction-is-not-rolled-back-even-after-the-initial-refactor branch from d315a3c to c3806f5 Compare April 5, 2023 15:16
@vilmosnagy vilmosnagy force-pushed the error-transaction-is-not-rolled-back-even-after-the-initial-refactor branch 3 times, most recently from 61835a4 to d6da5e5 Compare April 11, 2023 18:56
@vilmosnagy
Copy link
Contributor Author

vilmosnagy commented Apr 13, 2023

@mposolda @hmlnarik could you help me with this issue? Do you agree with me that the user could still break the registration flow, and if so, what do you think about my proposed changes?

@vilmosnagy vilmosnagy force-pushed the error-transaction-is-not-rolled-back-even-after-the-initial-refactor branch from d6da5e5 to 32ecf1e Compare April 14, 2023 15:29
@vilmosnagy
Copy link
Contributor Author

@mposolda @hmlnarik could you take a look at my changes pls? It should solve the bug I've reported, and all the tests pass.

@vilmosnagy vilmosnagy force-pushed the error-transaction-is-not-rolled-back-even-after-the-initial-refactor branch from 32ecf1e to 691a015 Compare April 14, 2023 17:15
@vilmosnagy vilmosnagy changed the title BUG: Adding a failing test from #17644. The #19488 PR seems not to solve it BUG: Follow up from #19488, user registration flow fixed. Apr 14, 2023
@vilmosnagy vilmosnagy force-pushed the error-transaction-is-not-rolled-back-even-after-the-initial-refactor branch from 691a015 to 7063b8e Compare April 17, 2023 14:55
@ghost ghost added the flaky-test label Apr 17, 2023
@vilmosnagy vilmosnagy force-pushed the error-transaction-is-not-rolled-back-even-after-the-initial-refactor branch 2 times, most recently from 42dbe46 to bd651e0 Compare April 24, 2023 08:44
@vilmosnagy vilmosnagy force-pushed the error-transaction-is-not-rolled-back-even-after-the-initial-refactor branch from bd651e0 to d379e56 Compare April 26, 2023 18:10
@ahus1
Copy link
Contributor

ahus1 commented Sep 1, 2023

Thank you for preparing this fix, @vilmosnagy.

@sguilhen and I had a look and found that while your proposed fix prevents the error message being shown, it prevents the safety measures in AuthenticationProcessor#setAutheticatedUser() which check if the user has already been set.

I pushed one more commit to this PR, which now adds the same check before creating the user. This way, when a user uses the back navigation and attempts a registration, they will see an error message, and no user would be created.

I ran the UserStorageTest tests locally and they passed for me. @sguilhen and I also did a manual test, and it looked good to us. I'm now waiting for the CI to complete.

Please let me know your thoughts on this change before I go ahead and merge it.

Thanks!

Comment on lines 69 to 70
*
* If there was another user attached to this flow calling this method overrides the previous setting.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ahus1 I think with your rework this should be removed as well, but I'm not a 100% sure.

Suggested change
*
* If there was another user attached to this flow calling this method overrides the previous setting.

@vilmosnagy
Copy link
Contributor Author

@ahus1 thanks for the review & rework, it looks good to me.

I've added a small suggestion - my original change would have changed the setUser function a bit. But with your rework the javadoc change is not needed.

Thanks again :)

@ahus1 ahus1 force-pushed the error-transaction-is-not-rolled-back-even-after-the-initial-refactor branch from b51763d to 1a6c9cf Compare September 5, 2023 08:37
@ahus1
Copy link
Contributor

ahus1 commented Sep 5, 2023

@sguilhen - could you please add your review to this issue? Once it has been reviewed, I'd then squash and merge it. I might also ask Marek P. for a review as he's involve in the core things.

Thanks!

@ahus1 ahus1 requested a review from sguilhen September 5, 2023 12:05
Copy link
Contributor

@sguilhen sguilhen left a comment

Choose a reason for hiding this comment

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

Approving as this reflects what @ahus1 and I discussed last week about the proper way to fix this.

@ahus1
Copy link
Contributor

ahus1 commented Sep 5, 2023

@mposolda - this is now ready to be merged IMHO, both @sguilhen and me looked into this.
As this touches the "core" parts of Keycloak, I ask you or someone from your team for a review.

Once your review is in, I will squash and merge it.

Thanks!

@mposolda
Copy link
Contributor

mposolda commented Sep 7, 2023

@ahus1 @vilmosnagy @sguilhen Thanks for the updates. I've did some testing of it and updated few things when looking into this. I've sent different PR #23064 with your commits and my commit on top of that. We can squash during merge possibly. In summary what I did was:

  • Moved the changes to RegisterTest instead of UserStorageTest. As UserStorageTest is related to user storage, but this bug is not specific to user-storage though? In theory, if we later remove old store and possibly UserStorageTest, this test might be lost as it would be removed together with that. Also it allows to simplify test a bit IMO

  • Added check also to RegistrationUserCreation.buildPage . I think that this improves usability. With the previous approach, the registration page was displayed and then after filling whole registration page with all the details, the error was displayed to the user. This is not very great for usability (especially in case when registration page contains lots of custom fields)

  • Changed the message a bit to Action Expired. instead of Login timeout as there is not technically any timeout and hence Action Expired seems to me a bit more appropriate. Also added some details to the event. But these points are minor IMO.

WDYT about those changes? If you're ok with it, can we go with the alternative PR instead of this one?

@ahus1
Copy link
Contributor

ahus1 commented Sep 7, 2023

@mposolda - I really like the change you did so the registration page doesn't show up any more. Closing this one, and continuing the discussion on the other PR.

@ahus1 ahus1 closed this Sep 7, 2023
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.

Can create a user without the registration flow finished properly (reopened #17644)
7 participants