django_firebase_scrypt
A Django password hasher based off scrypt to use for user accounts imported from Firebase.
Installation
Install dependencies according to your Python version and OS:
# Debian/Ubuntu
$ sudo apt-get install build-essential libssl-dev python-dev
# Fedora, RHEL
$ sudo yum install gcc openssl-devel python-devel
# Alpine Linux (Docker Containers)
$ apk add gcc openssl-dev python-dev
# (If you're on Python3, install the Python3 versions of the above packages)
# Mac
# Without setting the flags below, install will fail to find the necessary files
$ brew install openssl
$ export CFLAGS="-I$(brew --prefix openssl)/include $CFLAGS"
$ export LDFLAGS="-L$(brew --prefix openssl)/lib $LDFLAGS"
Then install this package
pip install django-firebase-scrypt
Usage
Add this to your hashers settings.py like so
PASSWORD_HASHERS = (
'django_firebase_scrypt.FirebaseScryptPasswordHasher',
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
'django.contrib.auth.hashers.SHA1PasswordHasher',
'django.contrib.auth.hashers.MD5PasswordHasher',
'django.contrib.auth.hashers.CryptPasswordHasher',
'django.contrib.auth.hashers.Argon2PasswordHasher',
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
)
# Retrieve these from the Firebase console - see https://firebaseopensource.com/projects/firebase/scrypt/
FIREBASE_SIGNER_KEY = "jxspr8Ki0RYycVU8zykbdLGjFQ3McFUH0uiiTvC8pVMXAn210wjLNmdZJzxUECKbm0QsEmYUSDzZvpjeJ9WmXA=="
FIREBASE_SALT_SEPARATOR = "Bw=="
FIREBASE_ROUNDS = 8
FIREBASE_MEMCOST = 14
You can also move FirebaseScryptPasswordHasher to the bottom of your hashers if you only want to use it to validate
old, migrated hashes instead of generating them for new users.
Migration
Migrate your Firebase users to Django. You can do so as follows:
# Grab your users and their password hashes using the auth:export command
$ auth:export users.json
import json
import django
django.setup()
from django.contrib.auth import get_user_model
from django_firebase_scrypt import FirebaseScryptPasswordHasher
User = get_user_model()
with open("users.json", "r") as user_file:
firebase_users = json.load(user_file)["users"]
for firebase_user in firebase_users:
django_password = f"{FirebaseScryptPasswordHasher.algorithm}${firebase_user['salt']}${firebase_user['passwordHash']}"
django_user = User(email=firebase_user["email"], password=django_password, ...any_other_user_fields)
django_user.save()
Metadata
Release files for django-firebase-scrypt 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_firebase_scrypt-0.0.2.tar.gz | 3.2 kB | Without provenance | Details for django_firebase_scrypt-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_firebase_scrypt-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for django_firebase_scrypt-0.0.2-py3-none-any.whl |
Total release size: 7.4 kB
Release files / django_firebase_scrypt-0.0.2.tar.gz
| Download URL | django_firebase_scrypt-0.0.2.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18376267e800d9eefe0500f9f4128341c5cfeee52436bb669a6ba622e77d5398
|
|
BLAKE2b-256 checksum How to use checksums |
aa8fe449d00ae7d04668febac0decf42d06ac947b9f109f0ec36e2373f9f51f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1
|
Release files / django_firebase_scrypt-0.0.2-py3-none-any.whl
| Download URL | django_firebase_scrypt-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5460db77581ced70a3c2a87cbeb6bebad30813998d09e86ffe2f28f66f854e6
|
|
BLAKE2b-256 checksum How to use checksums |
33abf9f8a737435b45912109c58c467d6dacb5839864ff59c4d86c79678794ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1
|
Security for django-firebase-scrypt 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.