我能够在我的项目中使用Socialite按照本教程:http://www.codeanchor.net/blog/complete-laravel-socialite-tutorial/
一切正常,但我有一个安全问题。
if (!$request) {
return $this->getAuthorizationFirst($provider);
}
检查令牌。但这是检查令牌的正确方法吗?
当我看教程时,我注意到$this->getAuthorizationFirst($provider)
调用自定义AuthenticateUser
类中声明的getAuthorizationFirst
方法。
getAuthorizationFirst
方法只是强制socialite驱动程序将用户重定向到提供商(Facebook、Github、Twitter等),以便针对提供商对用户进行身份验证。然后,该进程将经过身份验证的用户返回给调用应用程序。
// Authenticate by connecting to the Provider API
private function getAuthorizationFirst($provider) {
return $this->socialite->driver($provider)->redirect();
}
// Provider returns authenticated user for post-authentication processing
private function getSocialUser($provider) {
return $this->socialite->driver($provider)->user();
}
这与Socialite公开的过程有关,即重定向并返回到指定的url以进行身份验证后的用户处理。
从安全角度来看,这依赖于应用程序调用提供者的API并获得经过身份验证的用户。
Socialite只是公开了一个用于身份验证的重定向和返回方法。如果不首先重定向到提供程序API,您将无法进行OAuth身份验证。
这个教程看起来在很大程度上是基于Jeffrey Way在Laracasts.com上的教程,可以在这里找到:
https://laracasts.com/series/whats-new-in-laravel-5/episodes/9