gpt4 book ai didi

django - python社交身份验证重复条目

转载 作者:行者123 更新时间:2023-12-01 10:49:36 25 4
gpt4 key购买 nike

我在 Django 中使用 python-social-auth。我想通过 facebook 授权,但之前,我已经使用 facebook 使用的电子邮件以默认方式(电子邮件,密码)注册。我可以将Facebook帐户与注册帐户相关联吗?我试图搜索,但一无所获

最佳答案

检查 Associate users by email , 那应该解释如何去做。

Associate users by email

Sometimes it’s desirable that social accounts are automatically associated if the email already matches a user account.

For example, if a user signed up with his Facebook account, then logged out and next time tries to use Google OAuth2 to login, it could be nice (if both social sites have the same email address configured) that the user gets into his initial account created by Facebook backend.

This scenario is possible by enabling the associate_by_email pipeline function, like this:

SOCIAL_AUTH_PIPELINE = (
'social_core.pipeline.social_auth.social_details',
'social_core.pipeline.social_auth.social_uid',
'social_core.pipeline.social_auth.auth_allowed',
'social_core.pipeline.social_auth.social_user',
'social_core.pipeline.user.get_username',
'social_core.pipeline.social_auth.associate_by_email', # <--- enable this one
'social_core.pipeline.user.create_user',
'social_core.pipeline.social_auth.associate_user',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details',
)

This feature is disabled by default because it’s not 100% secure to automate this process with all the backends. Not all the providers will validate your email account and others users could take advantage of that.

Take for instance User A registered in your site with the email foo@bar.com. Then a malicious user registers into another provider that doesn’t validate his email with that same account. Finally this user will turn to your site (which supports that provider) and sign up to it, since the email is the same, the malicious user will take control over the User A account.

编辑:将固定和复制的文档详细信息链接到此答案中。

关于django - python社交身份验证重复条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21839714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com