好,我有一个应用概念的小问题。我想使用laravel护照来区分资源和授权服务器。
我有一个OAuth2服务器和一个带有自制无状态身份验证系统的经典laravel应用。 我有一个带有Vue.js的SPA,可将登录请求发送到REST接口的laravel应用程序。 此应用程序名为GuzzleClient,用于发送oauth密码授予类型请求以获取令牌。
public function login(Request $request, Client $client)
{
$url = config('app.auth.server') .'/oauth/token';
$response = $client->post($url, [
'form_params' => [
'grant_type' => 'password',
'username' => $request->name,
'password' => $request->password,
'client_id' => config('auth.oauth.password.client-id'),
'client_secret' => config('auth.oauth.password.client-secret'),
]
]);
if ($response->getStatusCode() !== Response::HTTP_OK) {
return http_response_code($response->getStatusCode());
}
return response()->json($response->getBody()->getContent(), Response::HTTP_OK);
}
但是,如果我想保护API路由,则不能使用通行证提供的auth:api保护。
2个解决方案。
第二种解决方案可能更好。但是你觉得呢?您有什么想法或最佳做法吗?
阅读的感谢。