Did you ever solve this, i'm having the same problem
Laravel Passport and PKCE authentication - Do you need a session for the user to login?
I setup a PKCE authentication system for an API using Laravel Passport. At the moment this API is used by a SPA.
The authentication flow is the following :
-
User clicks on "login" on the SPA
-
User is redirected to the API /oauth/authorize endpoint (with all the pkce required parameters)
-
Now, that API endpoint requires the user to be authenticated. So the login page is shown (its a php Laravel served view)
-
The user logs in, clicks on authorize, and is redirected to the callback url of the SPA, which will then send a request to obtain the JWT token.
-
From this point all communication from the SPA and the API will use the JWT token only.
Everything works. Except I now have a few doubts.
Is it correct for the login on step 3 to be session based ? To set that up I simply used Laravel UI, which provides an already setup login functionality, which is session based.
If I visit the API login page again, by its own url, I am actually logged in (which is normal). Of couse if I logout from that page (it has also a logout button), I can still use the SPA normally, as I still have my JWT token which is used by Passport.
Should I refactor the login function of Laravel UI to not start a session ? Or maybe log the user out in some way after the redirect to the SPA callback url ?
Thanks
Please or to participate in this conversation.