Django中如何使用密码hasher片段? [英] How to use password hasher snippet in Django?

查看:117
本文介绍了Django中如何使用密码hasher片段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将Druap 7网站移动到django 1.7,而不会使用户密码失效,这被证明是令人生畏的。

I am trying to move Druap 7 site to django 1.7 without invalidating user passwords, and this proved to be daunting.

幸运的是,我发现这个问题和这个哈希代码段,但没有文档和作为django的新手,我不知道如何将代码片段集成到我的项目中。

Fortunately, I have found this SO question and this hashing snippet but there is no documentation and as a newbie to django, I have no clue how to integrate the snippet into my project.

非常感谢您的帮助。

推荐答案

您可以使用 密码_HASHERS

Django使用该列表中的第一个条目来存储密码,所有其他条目都是可用于检查现有 密码。

settings.py。

PASSWORD_HASHERS = (
    'django.contrib.auth.hashers.PBKDF2PasswordHasher',
    'myproject.myapp.drupal_hasher.DrupalPasswordHasher', # Check this out
    'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
    'django.contrib.auth.hashers.BCryptPasswordHasher',
    'django.contrib.auth.hashers.SHA1PasswordHasher',
    'django.contrib.auth.hashers.MD5PasswordHasher',
    'django.contrib.auth.hashers.CryptPasswordHasher',
) 

这篇关于Django中如何使用密码hasher片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆