Replies: 4 comments
-
Can you maybe set up a test repo of a fresh install to reproduce this? With the bare minimum changes needed to reproduce this behavior. Please commit your changes separately from the skeleton. |
Beta Was this translation helpful? Give feedback.
-
I don't know what you mean when you say "gets a guard". |
Beta Was this translation helpful? Give feedback.
-
I mean to me it makes sense a request would pass for both api and user guards... they literally have the exact same configuration. |
Beta Was this translation helpful? Give feedback.
-
So I started from scratch and right after the LDAP login it started showing the issues. This is the env config for the publicly available LDAP server I'm using to test:
Not sure if laravel has anything to do with it, at this point. I'll check out the adldap2 repo for more info |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
Although I'm assigning only one guard through the auth middleware e.g: auth:admin (I've also tried Auth::shouldUse('admin') ) Laravel automatically assigns multiple guards: api, user and admin
Weirdly enough, for the auth:user guard, it only assigns 2 guards: api and user.
So, my admin with id 2, gets access to the user with id 2.
Out of curiosity I created a laravel 7 project and tested my same code, and there I don't have this guard issue. auth:admin only gets admin guard, auth:user only gets user guard. So I'm pretty sure it's a 8.x specific issue.
Steps To Reproduce:
Create 2 separate guards in the config/auth.php file with providers (different models too)
I'm using driver jwt as I'm using tymon/jwt-auth package
Using the following controller method to login as my Admin
Sent an API request to login as admin, logged in successfully and received a token
Used the token on a user route (/me) and it responded with the user of same id.
Went to tinker to check the guards and this is the outcome:

Also checked from inside a function, admin gets 3 guards in total: api, user, admin
Beta Was this translation helpful? Give feedback.
All reactions