我正在尝试将数据从Parse.com迁移到我们自己的服务器。为此,还必须迁移用户密码。 Parse.com使用标准的bcrypt密码加密,密码以下列格式显示(How would I move passwords out of Parse to another server?):
$2a$10$UpoNYQ0YE/FRVrh3xt6QQeQ3HmTmskbW2Sfg5DX9fDQJnIHQd1LqG
如何将此字符串移动到Django auth_user表,以便Django接受
修改 我已经尝试根据 shtuff.it 建议在设置中添加BCrypt密码哈希:
PASSWORD_HASHERS = (
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
'django.contrib.auth.hashers.BCryptPasswordHasher',
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
'django.contrib.auth.hashers.SHA1PasswordHasher',
'django.contrib.auth.hashers.MD5PasswordHasher',
'django.contrib.auth.hashers.CryptPasswordHasher',
)
尝试将 bcrypt 添加到字符串的开头:bcrypt$2a$10$UpoNYQ0YE/FRVrh3xt6QQeQ3HmTmskbW2Sfg5DX9fDQJnIHQd1LqG
这给了我来自bcrypt hasher的“无效盐”消息。我也尝试使用字符串并将其带到bcrypt$<iterations>$<salt>$hash
形式或其他组合形式,但无法使“无效盐”消息消失。
答案 0 :(得分:2)
看起来你应该能够在settings.py中将bcrypt添加到PASSWORD_HASHERS:
https://docs.djangoproject.com/en/dev/topics/auth/passwords/#using-bcrypt-with-django
答案 1 :(得分:1)
这对我来说非常愚蠢。
我必须确保初始字符串中的bcrypt
后跟double $$:
bcrypt$$2a$10$UpoNYQ0YE/FRVrh3xt6QQeQ3HmTmskbW2Sfg5DX9fDQJnIHQd1LqG
。
标记 shtuff.it 回答,因为它实际上是正确的。