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

[5.5] Attempt to fix AuthenticateSession/remember_me issue #19843

Merged
merged 2 commits into from
Jul 6, 2017
Merged

[5.5] Attempt to fix AuthenticateSession/remember_me issue #19843

merged 2 commits into from
Jul 6, 2017

Conversation

themsaid
Copy link
Member

@themsaid themsaid commented Jun 30, 2017

This PR explains the issue with the current AuthenticateSession when login is done via the remember_me token.

When the session expires, $request->session()->has('password_hash') will return false so it'll log the user out even if he's logged in vie remember_me.

To fix this we store the user password hash while logged in, we save that to the remember_me token, and in case the user is being logged in via remember_me later we'll use that hash to compare with the current hash and see if the user should be logged out.

Note: while upgrading from 5.4 to 5.5 all remember_me cookies will be considered invalid and users will be logged out.

@taylorotwell
Copy link
Member

We'll probably really need to think through what happens when people upgrade from 5.4 to 5.5 if we are changing the handling of the recaller cookie. What will happen?

@themsaid
Copy link
Member Author

themsaid commented Jun 30, 2017

All remember_me cookies will be considered invalid and users will be logged out.

@sisve
Copy link
Contributor

sisve commented Jul 1, 2017

This PR explains the issue with the current AuthenticateSession when login is done via the remember_me token.

No, it doesn't. =) What is the issue? Do you want to logout a user from all devices they are remembered on when they change their password?

@taylorotwell
Copy link
Member

@sisve yes, we do.

@themsaid
Copy link
Member Author

themsaid commented Jul 2, 2017

@sisve sorry this was meant as explanation to Taylor and Adam since we were discussing the issue together, should have mentioned more context :)

@boynet
Copy link

boynet commented Jul 4, 2017

if we talking about it, does it possible in 5.5 to add a simple way of logging out a user from all his devices?

@@ -461,7 +461,7 @@ protected function ensureRememberTokenIsSet(AuthenticatableContract $user)
protected function queueRecallerCookie(AuthenticatableContract $user)
{
$this->getCookieJar()->queue($this->createRecaller(
$user->getAuthIdentifier().'|'.$user->getRememberToken()
$user->getAuthIdentifier().'|'.$user->getRememberToken().'|'.$user->getAuthPassword()
Copy link
Contributor

Choose a reason for hiding this comment

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

Really sending password here? :/

Choose a reason for hiding this comment

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

I'm also having trouble understanding how this can be safe, please advise.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not the password, it's just the hash.

Choose a reason for hiding this comment

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

Thanks. In that case, this was what confused me in Authenticatable.php:

public function getAuthPassword()
{
    return $this->password;
}

@lotsofbytes
Copy link

lotsofbytes commented Jan 18, 2018

All remember_me cookies will be considered invalid and users will be logged out.

I think this is important enough to be be mentioned in the Upgrade Guide. It took awhile to find the cause after the 5.5 upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants