简体   繁体   English

如何将 django.contrib.auth 中的现有用户与 Python Social Auth(Google 后端)相关联?

[英]How to associate existsing users from django.contrib.auth with Python Social Auth (Google backend)?

I have a Django app with a standard django.contrib.auth backend and have a lot of existing users, now I want to add login via Google account using Python Social Auth.我有一个带有标准django.contrib.auth后端的 Django 应用程序,并且有很多现有用户,现在我想使用 Python Social Auth 通过 Google 帐户添加登录。 Is there any way to allow login via Google account for existing users?有没有办法允许现有用户通过谷歌帐户登录? How should I associate it with existing users?我应该如何将其与现有用户相关联?

Is it okey to set up 'social_core.pipeline.social_auth.associate_by_email' ?设置'social_core.pipeline.social_auth.associate_by_email'吗?

So when user try to log in using Google account and already have an account (created using standard registration with password) in my app then will be automatically logged in. I don't want to allow creating new accounts using Python Social Auth, only allow to login via Google for existing users.因此,当用户尝试使用 Google 帐户登录并且已经在我的应用程序中拥有一个帐户(使用带密码的标准注册创建)时,将自动登录。我不想允许使用 Python Social Auth 创建新帐户,只允许为现有用户通过 Google 登录。

Yes Cox, you can use this pipeline but pay attention because according to the django doc:是的 Cox,您可以使用此管道但要注意,因为根据 django 文档:

This pipeline entry is not 100% secure unless you know that the providers enabled enforce email verification on their side, otherwise a user can attempt to take over another user account by using the same (not validated) email address on some provider.此管道条目不是 100% 安全的,除非您知道启用的提供商在他们这边强制执行 email 验证,否则用户可以尝试通过在某些提供商上使用相同(未验证)email 地址来接管另一个用户帐户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM