Skip to content

AuthorizationController gets TokenGuard instead of StatefulGuard #1602

@pontoffeltier

Description

@pontoffeltier
  • Passport Version: 11.3.0
  • Laravel Version: 9.42.2
  • PHP Version: 8.1.13
  • Database Driver & Version: mysql 8.0.30

Description:

I followed the documentation for Passport to implement "Authorization Code Grant with PKCE". When I am trying to send a GET request to /oauth/authorize, I get the following error message:

Laravel\\Passport\\Http\\Controllers\\AuthorizationController::__construct(): Argument #3 ($guard) must be of type Illuminate\\Contracts\\Auth\\StatefulGuard, Laravel\\Passport\\Guards\\TokenGuard given

What I found in the source code was, that with the PR 1577 the Laravel\\Passport\\Http\\Controllers\\AuthorizationController now has a third parameter with the type of Illuminate\\Contracts\\Auth\\StatefulGuard. The problem is, the only guard in this package (which is bound in the Laravel\Passport\PassportServiceProvider) is the TokenGuard - which does not implement the StatefulGuard interface.

I totally expect that I am missing something important here, but for now I think this is a bug.

Steps To Reproduce:

As stated in the documentation:

  • Install laravel/passport
  • In config/app.php set guards.api.driver to passport
   'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'api' => [
            'driver' => 'passport',
            'provider' => 'users',
        ],
    ],
  • Create a client: php artisan passport:client --public with ID set to 1 and default values for name and redirect
  • Make a GET request (I used postman) to /oauth/authorize - I tested with and without the query parameters, both give the same error response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions