-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix middleware sorting for authenticating sessions
- Loading branch information
1 parent
ee2958b
commit 50b46db
Showing
4 changed files
with
12 additions
and
3 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/Illuminate/Contracts/Session/Middleware/AuthenticatesSessions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Illuminate\Contracts\Session\Middleware; | ||
|
||
interface AuthenticatesSessions | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50b46db
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 commit seems to have brought up an issue with the
laravel-impersonate
package.Linking for reference: 404labfr/laravel-impersonate#154
50b46db
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.
Yup, this one seems to prevent any attempt to try and log in as a different user while being logged in (at least in Jetstream afaik). Worked well in 9.3.1. Maybe it's a jetstream Auth middleware that should also extend the new contract?
50b46db
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 have just installed a fresh installation of Laravel 9.5, with Jetstream installed and I was getting an error when logging in/registering a new user.
I believe it's related to this.
Method Illuminate\Auth\SessionGuard::getDefaultDriver does not exist.
I have been forced to downgrade to laravel 9.3
50b46db
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.
yes same here!
50b46db
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 commit is correct - I'm not reverting it. If it breaks that impersonate package that is something they likely need to fix on their end.
It is likely broken because when they impersonate another user the session can no longer be authenticated because the password in the session no longer matches the impersonated user's password. In short, they would need to update the session with the hash of the impersonated user's password.
It was only working before because AuthenticateSession was totally broken and being run in the wrong order. Now that it is actually working correctly it has surfaced this oversight in the impersonation package.
50b46db
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.
@taylorotwell I don't know if I would say this is an oversight in an impersonation package... I have an app doing impersonation just via Auth::loginUsingId() and it causes the user to be logged out for the reason you specified.
...but yes, when using loginUsingId with Sanctum/Inertia, this is essentially trying to compare
password_hash_sanctum
againstpassword_hash_web
and logs the user out.Justing noting: Taylor responded in this thread (laravel/jetstream#997). This just is something that shouldn't have been allowed before and requires adding the current user's password hash to the session (as he stated above).