How to use password hasher snippet in Django?

2019-08-16 10:59发布

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条回答
SAY GOODBYE
2楼-- · 2019-08-16 11:27

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',
) 
查看更多
登录 后发表回答