laravel 护照授权码 - 要求授予权限,是否有必要?
laravel passport auth code - asking to grant permissions, is it nessecarry?
我正在寻找有关授权我自己的 SPA 时如何使用 Oauth 授权代码 PKCE 授予的一些说明。
所以当我从我的 SPA 重定向到后端时(当然是在我登录之后)我得到了这个:
现在我明白了,如果我想使用 google 或 Twitter 登录我的应用程序,这很有意义。
但是如果我想登录到后端应用程序以使用我的 SPA 获取令牌 - 有没有办法避免每次用户登录时出现这种情况?有道理吗?
我想从用户的角度来看是这样的:
- 点击登录
- 重定向到后端伪装成 SPA(视觉上)
- 登录
- 直接返回 SPA,无需确认这些内容
主要是想了解一下SPA的流程。我假设并怀疑我想要的根本不可能?
是的,你可以:)
创建您自己的 Passport 客户端。
<?php
declare(strict_types=1);
namespace App\Models;
class PassportClient extends \Laravel\Passport\Client
{
/**
* Determine if the client should skip the authorization prompt.
*
* @return bool
*/
public function skipsAuthorization()
{
// todo: add some checks, e.g. $this->name === 'spa-client'
return true;
}
}
并更新您的 App\Providers\AuthServiceProvider
。
public function boot()
{
// ...
Passport::useClientModel(PassportClient::class);
}
我正在寻找有关授权我自己的 SPA 时如何使用 Oauth 授权代码 PKCE 授予的一些说明。
所以当我从我的 SPA 重定向到后端时(当然是在我登录之后)我得到了这个:
现在我明白了,如果我想使用 google 或 Twitter 登录我的应用程序,这很有意义。
但是如果我想登录到后端应用程序以使用我的 SPA 获取令牌 - 有没有办法避免每次用户登录时出现这种情况?有道理吗?
我想从用户的角度来看是这样的:
- 点击登录
- 重定向到后端伪装成 SPA(视觉上)
- 登录
- 直接返回 SPA,无需确认这些内容
主要是想了解一下SPA的流程。我假设并怀疑我想要的根本不可能?
是的,你可以:)
创建您自己的 Passport 客户端。
<?php
declare(strict_types=1);
namespace App\Models;
class PassportClient extends \Laravel\Passport\Client
{
/**
* Determine if the client should skip the authorization prompt.
*
* @return bool
*/
public function skipsAuthorization()
{
// todo: add some checks, e.g. $this->name === 'spa-client'
return true;
}
}
并更新您的 App\Providers\AuthServiceProvider
。
public function boot()
{
// ...
Passport::useClientModel(PassportClient::class);
}