【问题标题】:The security of the social network authentication using Laravel Socialite使用 Laravel Socialite 的社交网络认证的安全性
【发布时间】:2018-07-13 10:44:00
【问题描述】:

我在 Laravel 应用程序中使用 Socialite 进行社交网络身份验证。我想使用社交网络添加注册,而无法通过输入用户名和密码使用经典注册方法。目前,我决定创建一个包含名称和用户名的用户模型,用于授权,并为每个社交网络在 db 中单独表,其中包含来自社交网络的 user_id 和 id 作为 PK。

当系统在所选社交网络中接收到用户的 ID 时,它会检查该 ID 的相应表,如果它存在,则获取用户 ID 并向系统验证用户身份。如果没有 - 添加那里并进行身份验证。

处理来自社交网络的响应的函数:

public function handleProviderCallback($social)
{
    $userSocial = Socialite::driver($social)->user();

    $registeredUser = DB::table($social.'_accounts')->find($userSocial->id);

    if(!empty($registeredUser)) {
        Auth::loginUsingId($registeredUser->user_id);
    }else{
        $user = new User;
        $user->name = $userSocial->name;
        $user->username = 'user2222'; //will be implementer in future
        $user->avatar = $userSocial->avatar;
        $user->save();

        DB::table($social.'_accounts')->insert(['id' => $userSocial->id, 'user_id' => $user->id ]);
        Auth::loginUsingId($user->id);
    }

        return redirect()->action('HomeController@index');
}

问题是关于安全性的,您能否解释一下该解决方案是否非常安全?我的意思是没有密码的身份验证,以防万一从社交网络接收用户的身份。是否可以伪造来自社交网络的查询以访问 smb'a 帐户?

【问题讨论】:

  • 无密码组织认证的最佳方式是什么?

标签: php laravel security authentication laravel-socialite


【解决方案1】:

由于您使用的是 oAuth,因此这是用户身份验证的首选方法。

由于您使用的是社交名流,它会自动检查提供者以防止发出虚假请求。 因此,是的,这将被认为是安全的。

【讨论】:

    猜你喜欢
    • 2016-11-05
    • 2018-05-11
    • 2014-03-24
    • 1970-01-01
    • 2020-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-27
    相关资源
    最近更新 更多