简体   繁体   English

Django身份验证问题-user.save()更改密码哈希

[英]Django authentications problems - user.save() changes password hash

I am experiencing an odd authentication problem in Django 1.4.5: 我在Django 1.4.5中遇到一个奇怪的身份验证问题:

As soon as I call user.save() the password hash changes and does not check successfully against the specified raw password: 一旦我调用user.save(),密码哈希就会更改,并且不会针对指定的原始密码成功检查:

In [17]: user.check_password('test')
Out[17]: False

In [18]: user.set_password('test')

In [19]: user.check_password('test')
Out[19]: True

In [20]: user.save()

In [21]: user.check_password('test')
Out[21]: False

The password is hashed with the pbkdf2_sha256 hasher: 密码使用pbkdf2_sha256哈希器进行了哈希处理:

In [22]: user.password
Out[22]: 'pbkdf2_sha256$10000$Aj5RbYndelmz$j35cic6UBh/HWnD//7TMfGWEtt7j4+T6970lOezpc1U='

So even after creating a super user: 因此,即使在创建超级用户之后:

python manage.py createsuperuser

I cannot log in with the credentials specified. 我无法使用指定的凭据登录。

Why does user.save() change the password hash and how can I solve this issue? 为什么user.save()更改密码哈希,我该如何解决此问题?

OK, I found some code that a developer was calling via the pre_save signal. 好的,我找到了一些开发人员正在通过pre_save信号调用的代码。 I fixed a bug in this code and now the problem is solved. 我修复了此代码中的错误,现在问题已解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM