Skip to main content

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.

Quick start

Install django_drupal_auth_backend:

$ 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',
)

Migrating users

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  user1@example.com   t   f
user2   drupal_sha512$CsaltsaltA112iY375iFdNhp.gYEWxwlWtXdhjl.8hY7BufRTJ1u  user2@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:

$S$CsaltsaltA112iY375iFdNhp.gYEWxwlWtXdhjl.8hY7BufRTJ1u

… whereas the migrated passwords need to be of the form:

drupal_sha512$CsaltsaltA112iY375iFdNhp.gYEWxwlWtXdhjl.8hY7BufRTJ1u

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.

Full documentation

(needs additional documentation)

Contributing

Contributions are welcome.

Licensing

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.

Release files for django-drupal-auth-backend 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-drupal-auth-backend 1.0.3
File Size Uploaded
django-drupal-auth-backend-1.0.3.tar.gz 18.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-drupal-auth-backend 1.0.3
File Interpreter ABI Platform
django_drupal_auth_backend-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 26.8 kB

Release files / django-drupal-auth-backend-1.0.3.tar.gz

Download URL django-drupal-auth-backend-1.0.3.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0860098883cd0f75d081a341e9aec8adaf55c41f32b6f993a49cf607c80fd456
BLAKE2b-256 checksum
How to use checksums
42909e73b11650829bf262c4d69e68905600dea4ca7114d40294ed7cf48cb8d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_drupal_auth_backend-1.0.3-py3-none-any.whl

Download URL django_drupal_auth_backend-1.0.3-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d602b083ec10267af23ba0548b0d8ff0c1e90f45680d86d90ecd60ead2b36183
BLAKE2b-256 checksum
How to use checksums
774a034a1ba5522d47d22a947da2b4f4eb651e4957876050b0a5a565e223c770
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page