Skip to content
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

[2.x] Fix user provider in sanctum guard #225

Merged
merged 3 commits into from
Nov 23, 2020

Commits on Nov 22, 2020

  1. Add failing tests for the sanctum guard provider

    These tests prove that the `sanctum` guard is not properly configured:
    
    The `Laravel\Sanctum\Guard` callable accepts the specified provider in the constructor from the configuration, and validates if the provider model matches the authenticated model. This part is working correctly.
    
    In the service provider, the actual guard `Illuminate\Auth\RequestGuard` is constructed with the default application provider which is `null`, instead of the specified provider in the configuration.
    
    So, calling `Auth::guard('sanctum')->user()` or `Auth::guard('sanctum')->validate()` will succeed because it's using the user provider configured in the service provider.
    
    But `Auth::guard('sanctum')->getProvider()` returns `null`.
    sebdesign committed Nov 22, 2020
    Configuration menu
    Copy the full SHA
    2c859e1 View commit details
    Browse the repository at this point in the history
  2. Pass the user provider to the sanctum guard

    This provides the specified user provider to the `sanctum` guard.
    
    Without that, the `Illuminate\Auth\RequestGuard` is constructed without a user provider by default, which is inconsistent with the `Laravel\Sanctum\Guard` callable which accepts the specified user provider.
    sebdesign committed Nov 22, 2020
    Configuration menu
    Copy the full SHA
    6336435 View commit details
    Browse the repository at this point in the history

Commits on Nov 23, 2020

  1. Configuration menu
    Copy the full SHA
    c481e0d View commit details
    Browse the repository at this point in the history