如何使用具有Django身份验证的惠而浦散列?

[英]How can I use the Whirlpool hash with Django authentication?


We have a system written in PHP where account passwords are stored as the first 128 chars of a whirlpool hash of the password.

我们有一个用PHP编写的系统,其中帐户密码存储为密码的惠而浦散列的前128个字符。

I'd like to transition to handling the logins with Django without changing the database or asking users to change their passwords. Also, I'd prefer to stick with whirlpool vs. the less secure hashes Django has built in. I found a python (C) implementation of Whirlpool which seems to work fine.

我希望过渡到使用Django处理登录,而无需更改数据库或要求用户更改密码。此外,我更喜欢使用whirlpool和Django内置的不太安全的散列。我发现了一个python (C)实现的Whirlpool,它似乎可以很好地工作。

How can I change the Django password checking function to use Whirlpool rather than SHA1/MD5?

如何更改Django密码检查函数以使用Whirlpool而不是SHA1/MD5?

1 个解决方案

#1


2  

Basically you want to write your own authentication back-end. Fortunately, this can be done very easily.

基本上,您希望编写自己的身份验证后端。幸运的是,这很容易做到。

It's as easy as:

这是一样容易:

class MyBackend:
    def authenticate(self, username=None, password=None):
        # Check the username/password and return a User.

Then all you need to do is specify the back-end class by setting AUTHENTICATION_BACKENDS to be ('django.contrib.auth.backends.YourCustomBackend',).

然后您需要做的就是通过设置AUTHENTICATION_BACKENDS来指定后端类(' django.致歉. authb .back . yourcustom后端')。

See: http://docs.djangoproject.com/en/dev/topics/auth/#specifying-authentication-backends

见:http://docs.djangoproject.com/en/dev/topics/auth/ specifying-authentication-backends

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2010/02/22/7200d5fb88e41e6d2cf2c9c2edc1593e.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告