-
Notifications
You must be signed in to change notification settings - Fork 825
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
ENH Refactor password reset to support SameSite=Strict #11566
base: 5
Are you sure you want to change the base?
ENH Refactor password reset to support SameSite=Strict #11566
Conversation
Performing an immediate redirect on a request from an external website, such as a web-based email client, causes the new request to be treated as external, and when the session cookie is set to Samesite=Strict, this prevents the cookie from being sent by the browser, triggering a fresh session. This meant that the existing password reset mechanism would not function in this mode, as the AutoLoginHash was being stored in the session and immediately lost, triggering a redirect to the login form. This change refactors the change password handler to instead push the AutoLoginHash value into the change password form as a hidden field, ensuring it can be read during submission. It also includes broader test coverage of the change password handler, though this remains incomplete due to time constraints.
9605a37
to
9b74757
Compare
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.
Haven't really looked at this properly, just saw some red thumbs sticking out.
* @param Member $member | ||
* @param string $token | ||
*/ | ||
protected function setSessionToken($member, $token) |
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.
We can't remove protected
functions in a minor release, as they count as part of our "Public API" - see https://docs.silverstripe.org/en/5/project_governance/public_api/
@@ -319,10 +291,18 @@ public function doChangePassword(array $data, $form) | |||
* | |||
* @return HTTPResponse | |||
*/ | |||
public function redirectBackToForm() | |||
public function redirectBackToForm(?int $withMemberID = null, ?string $withToken = null) |
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.
We can't amend public method signatures in a minor release, as they count as part of our "Public API" - see https://docs.silverstripe.org/en/5/project_governance/public_api/
Might point this at CMS 6 if we wanna go ahead with it - will require tweaks to the MFA module subclasses too, and I don't think there's a clean way to refactor it without breaking semver. |
Sounds like a plan to me. |
Description
Performing an immediate redirect on a request from an external website, such as a web-based email client, causes the new request to be treated as external, and when the session cookie is set to Samesite=Strict, this prevents the cookie from being sent by the browser, triggering a fresh session. This meant that the existing password reset mechanism would not function in this mode, as the AutoLoginHash was being stored in the session and immediately lost, triggering a redirect to the login form.
This change refactors the change password handler to instead push the AutoLoginHash value into the change password form as a hidden field, ensuring it can be read during submission.
It also includes broader test coverage of the change password handler, though this remains incomplete due to time constraints.
Manual testing steps
Enable SameSite=Strict on session cookies:
Issues
Pull request checklist