Git Product home page Git Product logo

django-plaintext-password's Introduction

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.

django-plaintext-password's People

Contributors

realorangeone avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.