How to use password hasher snippet in Django?

无人久伴 提交于 2020-01-07 07:49:25

问题


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

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.

So greatly appreciate your help.


回答1:


You can use PASSWORD_HASHERS

Django uses first entry in that list to store password and all the other entries are valid hashers that can be used to check existing passwords.

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',
) 


来源:https://stackoverflow.com/questions/28077859/how-to-use-password-hasher-snippet-in-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!