Authentication backend for Django that works with legacy Drupal 7 accounts.
This package provides an authentication backend that can be used to facilitate migrating users from a Drupal-based website into a Django-based web application.
$ pip install django_drupal_auth_backend
In your settings module you will need to add the new hasher to :
PASSWORD_HASHERS = ( 'django.contrib.auth.hashers.PBKDF2PasswordHasher', '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', 'django_drupal_auth_backend.hashers.DrupalPasswordHasher', )
You will need to create a user entry for each user of the old system. While this will vary from application to application (depending on whether you override the default user model provided by Django), the basic step is to copy your user table into Django’s user table. If you are using Postgres, you can copy the users in with something like this:
COPY INTO auth_user (username, password, email, is_active, is_staff) FROM STDIN; user1 drupal_sha512$FYEWxwlWtUUj8uB5QN2K0X9lNrnRl/hLpN3Qp8GK7v8emyc9eRsf firstname.lastname@example.org t f user2 drupal_sha512$CsaltsaltA112iY375iFdNhp.gYEWxwlWtXdhjl.8hY7BufRTJ1u email@example.com t f \.
The most important thing to note with migrated accounts is that the hashed password being migrated needs to be modified slightly. Drupal passwords are of the form:
… whereas the migrated passwords need to be of the form:
The important distinction is that the $S$ at the start of the hash needs to be converted to drupal_sha512$ for the Django authentication backend subsystem to be able to recognize it and assign it to the DrupalPasswordHasher. Note that the example table copy command above is using passwords of the right form.
(needs additional documentation)
Contributions are welcome.
This software is licensed under the GNU 3.0 license to comply with the Drupal license requirements for derivative works. Parts of this code are directly converted to Python from code in the Drupal project.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|django_drupal_auth_backend-1.0.3-py3-none-any.whl (8.2 kB) Copy SHA256 hash SHA256||Wheel||3.6||Mar 16, 2018|
|django-drupal-auth-backend-1.0.3.tar.gz (18.6 kB) Copy SHA256 hash SHA256||Source||None||Mar 16, 2018|