2 回答

TA贡献1772条经验 获得超5个赞
我解决了它。
我们必须使用以下命令设置配置/身份验证.php文件:
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
'hash' => false,
],
],

TA贡献1818条经验 获得超3个赞
与此同时,我发现了文档中提到的另一种解决方案:
https://lighthouse-php.com/master/security/authentication.html#global
简而言之,我需要将尝试身份验证中间件添加到灯塔配置中。我使用这个@auth(警卫:“api”)添加到我的所有类型。
- 2 回答
- 0 关注
- 101 浏览
添加回答
举报