-
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
TokenGuard query token twice #382
Comments
I also see this happening on my API using Laravel Passport (v2.0.11) |
Finally found someone with the same "problem", it's driving me nuts to figure out why this is happening. I have a simple app to test it, installed passport and made vue make a request to some route with an authorization header. The following queries are executed, in this order:
(removed the token for presentation purposes) |
Same issue here. |
still happening |
I am having the same issue here, passport/src/Guards/TokenGuard.php Line 109 in 9dbcc3d
Then the oauth_access_tokens is queried again right after: passport/src/Guards/TokenGuard.php Line 125 in 9dbcc3d
|
Same issue here, the fun part is that it's happening in the same try block |
Same issue, always 2 duplicated request to database |
Same issue |
Same issue! |
Same issue here |
Since this is an optimization rather than something blocking, feel free to send in a PR to solve this problem. |
@driesvints this is not optimization, it certainly looks like a bug. For me select * from "oauth_access_tokens" where "id" = token_id' limit 1 Backtrace: First request:
Second request:
|
@tylik1 this isn't exactly blocking or causing issues. If you can optimize the process in a clean way which reduces the queries to one feel free to send in a PR. |
Okay. I'll re-open this but mark it as an enhancement for now. |
Thanks but you forgot to re open this. |
That's because laravel passport uses their own revoke check and second one is from league/oauth2-server required package. I think laravel passport should execute their check if token is revoked or find some other solution for it. I`ll show u both calls thet are in /passport/src/Guards/TokenGuard.php line 152
and /league/oauth2-server/src/AuthorizationValidators/BearerTokenValidator.php line 88
|
Thanks @Vatia13 for insights |
Just did an audit of my SQL queries and notice this is still happening as of Laravel 5.8 - any progress on this? |
@Patskimoto We're open to pull requests. |
is there any way to avoid these repeated queries? |
in mysql the function |
Can anyone please pinpoint the exact locations where these double calls are made in the current Passport code? Things have changed a bit since and I can't find them. And not inside the TokenRepository I mean. Where the calls to the repository are made. |
Same issue here using |
Please stop reporting this or asking when this will be fixed. We need to pinpoint the exact locations where the calls are made (like I've asked above). The comments above don't help to solve the issue at hand. |
L127, begins in passport/src/Guards/TokenGuard.php Lines 125 to 129 in 5def15d
L175, calls \League\OAuth2\Server\ResourceServer::validateAuthenticatedRequest($request) passport/src/Guards/TokenGuard.php Lines 167 to 177 in 5def15d
L145, continues in passport/src/Guards/TokenGuard.php Lines 142 to 147 in 5def15d
|
I need solution for this issue also. I'm still using Passport 5.0 on Laravel 5.6 installed on my client server, and there is no way to upgrade into latest version. I hope somebody can help. Thank you. |
I am currently running a large scale application and this has a severe performance impact as they are all single transactions against the DB.. ended up writing my own TokenRepository to curb this issue. While I agree this isn't a bug, it's a deal breaker on large scale applications. |
@0plus1 how about sharing how you solved it or sending a pull request |
@taftse I created a package: https://github.com/overtrue/laravel-passport-cache-token |
This bug still happens... Laravel: v7.14.1 and Passport: v8.5.0 |
I'm gonna close this to prevent more "this is still a bug" comments. Welcoming prs. |
Since nobody has attempted any more prs I'm closing this. We're still welcoming prs if anyone wants to take up work on this. |
Great news all. It seems there's finally coming a fix for this one in Passport v13: #1751 |
The following sql statement is queried twice during a call to
TokenGuard::authenticateViaBearerToken()
function:The text was updated successfully, but these errors were encountered: