-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Adding the ability to use package with service-to-service Passport client #2467
Conversation
Thanks for all your work on this! |
@parallels999 & @drbyte perhaps one of you can help with this. Been testing this locally but run into a problem where the (permission)middleware always returns [
'client' => \Laravel\Passport\Http\Middleware\CheckClientCredentials::class,
]; For example: Route::group(['middleware' => 'client'], function() {
Route::get(...)->middleware('permission:edit-posts');
}); Almost as if the |
Regarding the 403, I'll have to wait til tomorrow to spend some time looking in detail. Regarding the currently-failing tests, it's because you changed (rearranged) the order in which the test-case roles/permissions were created, so the id numbers are out of sync with the tests. We can make those tests less rigid by querying the ID numbers before testing against them, but don't need to do that inside this PR, because it's unrelated. You could put them back in original order and we can clean them up in another PR. |
…issions in TestCase.
@drbyte, @erikn69, @parallels999 I did some more digging around and testing. I found that when using Passport v11 and providing But when making api requests the provided |
If someone uses a guard name different than
Did you set |
@parallels999 for the client credentials grant it shouldn't be used:
Also when I do add the Would it be possible to do something like the following: if($bearerToken && !$guard) {
Auth::guard('api'); // Or a configuration setting
} And later we could reset it to |
What about scopes? client-credentials-grant-tokens Route::get('/orders', function (Request $request) {
...
})->middleware('client:role-name-1,role-name-2'); |
@angeljqv what exactly do you mean? We don't change the working the |
I have never said that you should change the behavior of the
|
@angeljqv I prefer consistency. And I'm already using laravel-permission package for permissions on the web part of my project. So to me it only seems logical to also apply the permissions to the API part. That way I only have to deal with one "system" for permissions. |
ok, i got it |
@SuperDJ This is looking good. Do you have any remaining concerns about it? |
Also, are you comfortable squashing the commits into one and then force-pushing that commit back to this branch? |
@drbyte you can use squash merge PR and change the commit message |
Agreed. |
Unfortunately it's not an area where I have much experience. Does your own app need a solution to that? Or can we safely document it as a limitation for which help is welcomed?
|
@drbyte currently my app only needs to use the Client Credentials Grant. And that is working with the changes made in this PR. But we could add something to the docs indeed. Or maybe add another check after line 95 of Guard.php perhaps on line 100 of |
if the token uses User model, $user = $authGuard->user();
// For machine-to-machine Passport clients
if (! $user && $request->bearerToken()) {
$user = Guard::getPassportClient($guard);
} |
Isn't there some sort of beta release so things like this can be tested? |
We haven't usually released "betas" on this package. |
…nto dev-service-to-service-client
@drbyte made it an opt-in feature. That way is up to the end user to decide if they want to use it. |
@SuperDJ thanks for all your work on this. I'm going to merge it so it can be used in dev as beta etc. And if it is found that adjustments are required, those can be done via PR. |
No description provided.