Is it possible to change the Hashing algorithm in django_auth?

為{幸葍}努か 提交于 2019-12-11 03:15:04

问题


I have a running wiki with users. Now I want to write an app in Django to do a specific task.

I have to use my "old" users/groups database (which has a different hashing algorithm for passwords then django_auth) and sync it every now and then since my users already have a login which has to be the same everywhere.

I want to use django_auth as well.

Is it possible to change the Hashing algorithm in django_auth?

so that django auth uses a function I write to check whether the password inserted is right or wrong.

Thanks in advance, Senad. =)


回答1:


From Integrating with an Authentication System, chapter18 of djangobook

It’s possible to integrate Django with an existing authentication system — another source of usernames and passwords or authentication methods. You can override Django’s default database-based scheme, or you can use the default system in tandem with other systems.

Also, in this book, you can learn how to write your own Authentication Backend implementing two methods: get_user(id) and authenticate(**credentials).




回答2:


You can write a custom authentication backend that includes its own authenticate function to check passwords according to your custom hash. Of course, you'll need some way of distinguishing between the different types of users.




回答3:


Yes it's possible. See django-bcyrpt for an example. It will be easier to change in Django 1.4: https://docs.djangoproject.com/en/dev/releases/1.4/#improved-password-hashing



来源:https://stackoverflow.com/questions/8794512/is-it-possible-to-change-the-hashing-algorithm-in-django-auth

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