使用Python Social Auth进行无密码登录的自定义登录流程

时间:2014-06-10 12:42:16

标签: django django-authentication python-social-auth

对于我正在研究的Django项目,除了python social auth提供的社交认证方法之外,我还尝试实现并集成passwordless authentication流程。除了其他优势之外,这种方法对我来说最吸引人的部分是,它统一了注册和登录,就像在其他社交认证后端中一样。这提供了电子邮件身份验证的统一

每次用户想要登录(或注册)时,他们只会提交他们的电子邮件,通过电子邮件接收临时登录令牌,点击它,然后他们就会进入。持久的会话被启动,所以他们不会需要经常这样做。

我正在使用自定义EMAIL_VALIDATION_FUNCTION来发送电子邮件,如文档中所述,它会将令牌发送好。我的管道看起来像这样:

SOCIAL_AUTH_PIPELINE = (
    'social.pipeline.social_auth.social_details',
    'social.pipeline.social_auth.social_uid',
    'social.pipeline.social_auth.auth_allowed',
    'social.pipeline.social_auth.social_user',
    'social.pipeline.user.get_username',
    'social.pipeline.mail.mail_validation',
    'barrio.profiles.pipeline.authenticate_email',  # custom method to authenticate email
    'social.pipeline.social_auth.associate_by_email',
    'social.pipeline.user.create_user',
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details',
)

单击身份验证链接(即/ complete / email /?validation_code =)时,管道将从'social.pipeline.mail.mail_validation'恢复,并且管道中存在身份验证失败,执行永远不会到达我的自定义身份验证功能。

即使它这样做了,我也不清楚如何访问验证结果并检查它是否正常。

我应该使用自定义视图而不是将用户引导至“/ email / complete /”视图,而不是尝试在管道上执行此操作,而是将其引导至我的视图并进行身份验证?

Python社交认证非常适合其灵活性,但权衡是复杂性。有时我感到迷茫。谢谢你的帮助。

0 个答案:

没有答案