-
Notifications
You must be signed in to change notification settings - Fork 784
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
Allow to retrieve the current client through the RequestGuard #882
Comments
Any traction on this one...? :-) |
No sorry. Way too much other stuff on my plate atm. |
@driesvints Thx. Understandable.... :-) |
EDIT: I've noticed you explain a way to get it in #854. Would be great tho if you make this change for 9.x. Today, while updating to Laravel 7 I've noticed that when I'm trying to get the Client (Client Credentials Grant) from the request, in I'm interested in this functionality because I'm trying to know which other 'server/machine' made the request. It looks like the functionality is there but it's not accessible. It would be great to be able to call something like |
You can replicate what the token guard is doing as a macro on the request. It would involve a query so it may not be the cleanest solution but it would work. Request::macro('client', function () {
$server = app(ResourceServer::class);
$psr = $server->validateAuthenticatedRequest((new PsrHttpFactory(
new ServerRequestFactory,
new StreamFactory,
new UploadedFileFactory,
new ResponseFactory
))->createRequest(request()));
return \Laravel\Passport\Client::find($psr->getAttribute('oauth_client_id'));
}); Then you can just use |
Trying a variation of this with version 10 results in |
Figured it out. Because of pull request #1330 the implementation above should be switched to: use Nyholm\Psr7\Factory\Psr17Factory;
...
Request::macro('client', function () {
$server = app(ResourceServer::class);
$psr = $server->validateAuthenticatedRequest((new PsrHttpFactory(
new Psr17Factory,
new Psr17Factory,
new Psr17Factory,
new Psr17Factory
))->createRequest(request()));
return \Laravel\Passport\Client::find($psr->getAttribute('oauth_client_id'));
}); |
Any chance we could finally get this issue fixed? |
@taftse as soon as someone sends in a PR |
@driesvints I was looking at creating a PR for this. Does either of the following sound agreeable to you? Option 1:
Option 2:
The first option is obviously very breaking, I initially thought the second option one was not, but the |
@axlon gonna be real with you: I don't have the time atm to dig into that to review which would be better. It's best that you send in a PR according to your best insight at which one would be better. |
Thanks to @axlon, this feature will be available in the next major Passport release. |
Hey @driesvints, do you have any indication as to when the next major Passport release will be tagged? It seems it did not get one when Laravel 9 came out. |
Not yet. It's on my list but right now other things are keeping me from checking in on it. |
We should enhance the
RequestGuard
so it's able to retrieve the current client that's being used as an addition to #854.This probably requires some breaking changes and should target the next major release.
The text was updated successfully, but these errors were encountered: