-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Revoke all authorized applications on password reset #21325
Revoke all authorized applications on password reset #21325
Conversation
app/models/user.rb
Outdated
@@ -373,6 +373,15 @@ def reset_password(new_password, new_password_confirmation) | |||
super | |||
end | |||
|
|||
def clear_sessions! |
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.
This name feels a little misleading, given that what it's really doing is removing/revoking authorised applications and push subscriptions.
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.
Any suggestions for a clearer name?
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.
Hmm, maybe revoke_access
?
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.
revoke_tokens
would be even more explicit, I think
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.
I considered that, but it's also revoking access grants and deleting push subscriptions.
Maybe that's implementation detail.
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.
If I refactor this method to also delete session_activations
if it was used for change password, would the original name be more helpful?
Thank you for your contribution! I don't think it's addressing #20431 as this issue was explicitly about I am not completely sure we want that behavior, especially since current apps handle revoked tokens quite poorly (see #20431 (comment)) but I understand the reasoning, and I think revoking tokens in the password reset flow as addressed in this PR would cause less issue than doing it in the
The password reset is taken care of by
That would be great! This would be a new |
I started with the password reset to understand if this behavior is acceptable which I was hoping then to reuse for change password without removing the current session that is. If this behavior is currently not desired, I will remove marking the issue resolved. For now, will just add the controller test. |
it 'returns http success' do | ||
expect(response).to have_http_status(200) | ||
end |
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.
Is that actually the expected behavior?
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.
I see your point. So I changed the test expectation to redirection on success and render a error template on failure which might be better.
2a7b4fa
to
ace0341
Compare
@FrancisMurillo your commits are showing up as Unverified, as you've requested GitHub to require GPG signing for your account. Can you look into this? |
ace0341
to
2a57e6e
Compare
@ineffyble Was able to finally recover my keys and gpg sign the commits so they are now marked as verified. |
* Clear sessions on password change * Rename User::clear_sessions to revoke_access for a clearer meaning * Add reset paassword controller test * Use User.find instead of User.find_for_authentication for reset password test * Use redirect and render for better test meaning in reset password Co-authored-by: Effy Elden <[email protected]>
* Clear sessions on password change * Rename User::clear_sessions to revoke_access for a clearer meaning * Add reset paassword controller test * Use User.find instead of User.find_for_authentication for reset password test * Use redirect and render for better test meaning in reset password Co-authored-by: Effy Elden <[email protected]>
Clear all user sessions after a successful password reset if this is the desired behavior. I noticed that
User::reset_password!
is not really being invoked by the password reset flow so I am not sure if this is intentional as the tests are working as well. I would also like to add a controller test for this behavior but would need some guidance.For change password, the behavior is the same and may not clear the sessions except the current. So this might also be considered.
Steps I took when I tested with my instance: