-
Notifications
You must be signed in to change notification settings - Fork 785
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
Consuming API with JavaScript with no valid session keeps returning users data until refreshing the page #909
Comments
Heya, unfortunately we don't support this version anymore. Can you please try to upgrade to the latest version and see if your problem persists? If so feel free to reply and we'll try to have a look. |
@driesvints I can confirm that this problem persists on the latest version. As I said, the API still works (using passport cookie) after removing all user sessions and tokens from the db until manually refreshing the page. |
How is it possible that API calls can be made with tokens which are revoked? |
@driesvints Steps to reproduce:
passport/src/Guards/TokenGuard.php Lines 254 to 259 in 6cae8eb
|
@hafezdivandari can you please create a test app which reproduces this problem with the most minimal setup? I'd like to take a look at how you setup routes, controllers, middleware, etc. |
@hafezdivandari I thought we couldn't revoke tokens for a user created by |
Closing this issue because it's inactive, already solved, old or not relevant anymore. Feel free to reply if you're still experiencing this issue. |
FYI.. this is still an issue and came up on a security assessment of ours. Reproduced doing the following:
The issue is Passport is only checking the CSRF token against the laravel_token. It isn't validating if the laravel_token is still validate for a session in the sessions table. At least that is my understanding of the problem here. |
@jthunt hmm, I see. I'll try to look at this throughly when I find some time. Appreciating any help in the meantime. |
The This is really just one of the downsides of JWTs and there isn't much you can do. Any solution you can come up with ends up reinventing sessions. You can use the jti claim to assign a unique ID to each JWT and store either a whitelist or a blacklist but that sounds an awful lot like a session to me 😆. All you can really do is set a short expiration time and delete the cookie on logout. The expiration for the JWT is currently set to It might be a good idea to make this configurable separately. It's OK if the session lifetime is longer because you can destroy it server side. The JWT on the other hand can't be revoked. IMO it would be a good idea to update the docs to call this out, because it wasn't clear to me that the If |
It's worth mentioning that even if you don't use the |
Finally had time to look at this issue again. Thanks for clarifying so clearly @matt-allan. I've sent in a PR to the docs: laravel/docs#5993 |
On Laravel 5.5 and Passport 4.0 with Consuming API With JavaScript.
I am trying to logout other devices when user changes password. On the app, I listen for change password event and revoke all refresh/access token of the user (except the current one) and
\Illuminate\Session\Middleware\AuthenticateSession
added to take care of sessions (I also tested removing all user's sessions from the db);But the passport cookie is still valid and returns user data until page refresh, It is not enough to delete the cookie on logout event (Issue #85, PR #160) because in a case that user is logged out async and has no active session and no valid access token still can use the API with the passport cookie.
There should be a way to revoke transient tokens, invalidate passport cookies or maybe we should compare csrf of cookie with user's active sessions csrf.
The text was updated successfully, but these errors were encountered: