robsontenorio / laravel-keycloak-guard

🔑 Simple Keycloak Guard for Laravel
MIT License
434 stars 141 forks source link

Possible incompatibility with spatie-permission #93

Closed AntonioGiangrave closed 1 year ago

AntonioGiangrave commented 1 year ago

I configured laravel-keycloak-guard on my api. It works perfectly on standard routes, but on those with ->can(permission) (I use spatie-permission) access is systematically denied, as if the user weren't authenticated. I followed the installation instructions step by step.

In this way I get the authenticated user:

Route::middleware(['auth:api'])->group(function () {
    Route::get('test-auth', function (Request $request) {
        return  Auth::user();
    });
});

In this way I am rejected (with the old authentication the ability was recognized)

Route::middleware(['auth:api'])->group(function () {
    Route::get('test-auth', function (Request $request) {
        return  Auth::user();
    })->can('permission.list');
});