【问题标题】:Associate-only authentication with Python Social Authentication and Django仅关联身份验证与 Python 社交身份验证和 Django
【发布时间】:2013-12-11 19:41:29
【问题描述】:

为了一个简单的概念证明,我正在配置一个 Django 应用程序来进行身份验证 通过python-social-auth 对抗内部 OAuth2 服务器。注:我 我是 Django 新手,所以仍在尝试解决问题...

身份验证方案依赖于带外帐户同步 - 即, 只允许现有用户,不自动创建新用户。但是,那 记录在案的“仅关联”管道配置似乎不起作用 我认为的方式(在与get_usernamesocial_uid进行各种组合之后);我只能在创建自己的之后才能让它工作 管道方法返回带有“用户”键的字典。

我从这个配置开始 http://psa.matiasaguirre.net/docs/pipeline.html#authentication-pipeline:

SOCIAL_AUTH_PIPELINE = (
    'social.pipeline.social_auth.social_user',
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details'
)

但前两个 - social_userassociate_user - 如果 没有“用户”键。没有关于“用户”密钥如何获取的任何其他指导 人口稠密,我想出了:

SOCIAL_AUTH_PIPELINE = (
    'ccpoc.auth.load_user',
    'social.pipeline.social_auth.associate_user',
)

load_user 知道根据自定义键查找当前用户的位置 在 JSON 中返回。虽然它有效,但我不确定这是否在框架的“精神”中,或者我只是错过了一些东西。

【问题讨论】:

    标签: python django python-social-auth


    【解决方案1】:

    这行得通,这是符合应用程序精神的正确方法,我的文档并不完全正确,那里列出的单一关联管道假定用户已登录,这不是您的情况,但文档中没有详细说明。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-18
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 2019-03-03
      相关资源
      最近更新 更多