Skip to main content

https://github.com/RealOrangeOne/django-plaintext-password

Project description

django-plaintext-password

CI PyPI PyPI - Python Version PyPI - Wheel PyPI - Status PyPI - License

A Django password hasher to store passwords in plaintext.

"Should I use this in production?"

Oh definitely not. Storing passwords in plaintext is a very very bad thing. Django's defaults are incredibly secure and should be used unless you have a good reason not to.

For more on why using this in production is a terrible idea, check out How to store passwords.

When running deployment checks, this will throw a "CRITICAL" error if in use.

Installation and usage

pip install django-plaintext-password

Then add plaintext_password.PlaintextPasswordHasher to PASSWORD_HASHERS in settings.py. To ensure it's used by default, make it the first or only item.

How does it work?

By default, Django will store the password password123 in a format similar to:

pbkdf2_sha256$216000$gd57n4OWJrXh$Xs/TqhwJICOxsLONGlKXorjuWccooiuJmJOUaxbwcOQ=

This is good for security as the password has been both salted and hashed before being saved into the database, making it almost impossible to retrieve the original password. This library however, stores the password as-is:

plaintext$$password123

This makes searching by password possible, as well as comparing users passwords and allowing you to email users their passwords if they forget them - neat!

In addition to storing the values directly in the database for easy retrieval, the comparison is done simply with ==, rather than using secrets.compare_digest.

Why?

Well, why not?

Although in all seriousness, If as part of your tests you're creating a large number of users, or just a couple users but you've got a lot of tests, you can get quite a performance improvement by simplifying the password hasher.

Unfortunately due to a limitation (and feature) with Django, it's not possible to store just the value directly, it must be prefixed with the algorithm.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-plaintext-password-0.2.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-plaintext-password-0.2.0.tar.gz.

File metadata

File hashes

Hashes for django-plaintext-password-0.2.0.tar.gz
Algorithm Hash digest
SHA256 737da67ae2ef2b13362e236a34a270a27288d74277339f4499517816fc26938d
MD5 b1218d71d7985522b2cd8f001a6a9c6e
BLAKE2b-256 4ec1d17ff5bf814b274e1b3f4a230a2ee09d7d40e45c2ac5c032e9ecaa9a82dc

See more details on using hashes here.

Provenance

File details

Details for the file django_plaintext_password-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_plaintext_password-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ad0a328c17fbd1553b980d948b23062bf6d496377379df20ba031a1e81df1df
MD5 e673b8ed6520b7a7b5f30afe39320d10
BLAKE2b-256 81feaf63904f72a48d78da8b4365644b61c5d5cc91d158b7c0c631180cbef695

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page