dingo / dingo/api

guard in auth problem

Open
#1,541 3 comments 3 reactions 1 assignee Claimed by @specialtactics View on GitHub
an interesting one
Dominant language
PHP
Stars
9.4k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

| Q | A
| ----------------- | ---
| Bug? | no
| New Feature? | no
| Framework | Laravel
| Framework version | 5.5.y
| Package version | 2.0.0-alpha2
| PHP version | 7.1.y

config/auth.php
```
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'TLXAdminUsers',
],

'user' => [
'driver' => 'jwt',
'provider' => 'Users',
],

'staff' => [
'driver' => 'jwt',
'provider' => 'Staff',
]
]
```

config/api.php
```
'auth' => [
'jwt' => 'Dingo\Api\Auth\Provider\JWT'
],
```

Kernel.php
```
protected $routeMiddleware = [
'api-auth' => \Dingo\Api\Http\Middleware\Auth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \Studiomate\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,

'role' => \Laratrust\Middleware\LaratrustRole::class,
'permission' => \Laratrust\Middleware\LaratrustPermission::class,
'ability' => \Laratrust\Middleware\LaratrustAbility::class
];
```

I want to use 'staff' guard and 'user' guard in 'dingo auth' with 'jwt' on the route.
However, 'dingo auth' using 'jwt' seems to be able to use only the defaults defined in config / auth.php.
Is there a way to use 'staff' guard and 'user' guard on a route?

I know how to use 'auth:staff' on middleware by defining
```
'auth' => Illuminate\Auth\Middleware\Authenticate::class'
```
on routeMiddleware, This is also a problem because of an 500 error not 401 error.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.