This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Overview

This app provides a mixin class that adds fallback master password authentication to an existing backend, and a ready to use subclass of Django’s ModelBackend with master password authentication.

This could be dangerous and is generally not recommended for production, but is super handy for development and staging environments.

In a pinch it can also be used temporarily (with a strong password) to troubleshoot end-user issues in production environments, without having to reset their password.

Installation

Install with pip:

$ pip install django-master-password

Update the AUTHENTICATION_BACKEND setting:

AUTHENTICATION_BACKEND += ('master_password.auth.ModelBackend', )

If you want to use the optional make_password management command, update the INSTALLED_APPS setting as well:

INSTALLED_APPS += ('master_password', )

Usage

The MasterPasswordMixin.authenticate() method will first try to authenticate with its superclass, and then it will fallback to master password authentication.

The default implementation authenticates against the MASTER_PASSWORDS setting, which should be a dictionary with clear text or hashed passwords as keys, and callback functions (or None) as values.

A callback function must take a user object as its only argument, and should return True if the user is allowed to authenticate with that password.

For example, you might have one master password that cannot be used for staff or superuser accounts, and another that can be used for any account:

MASTER_PASSWORDS = {
    'user123': lambda u: not u.is_staff and not u.is_superuser,
    'superuser123': None,
}

The use of clear text master passwords is intended as a convenience during development. When DEBUG=False, you must use a strong hashed password with at least 50 characters, 1 digit, 1 uppercase letter, 1 lowercase letter, and 1 non-alphanumeric character:

MASTER_PASSWORDS = {
    'pbkdf2_sha256$'
    '20000$'
    'kGdCcfmJtsUY$'
    'euTmHbJ9sdHirlsM2MvUjHQPDJ6CZdu02gYrxY3aAbI=': None,
}

This is a failsafe against accidentally enabling an unsafe master password for production and staging environments.

You can generate a hashed password in Python:

>>> from django.contrib.auth.models import make_password
>>> print make_password('password123')
pbkdf2_sha256$20000$kGdCcfmJtsUY$euTmHbJ9sdHirlsM2MvUjHQPDJ6CZdu02gYrxY3aAbI=

Or use the make_password management command:

(venv)$ ./manage.py make_password
Password:
Hashed password: pbkdf2_sha256$20000$kGdCcfmJtsUY$euTmHbJ9sdHirlsM2MvUjHQPDJ6CZdu02gYrxY3aAbI=

Customising

If you are already using a custom auth backend, use the mixin class to add master password authentication to it. You will need to define a get_user_object(**kwargs) method, which should be the same as the authenticate() method on the superclass but without any password validation.

You can also override the get_master_passwords() method if you want to get master passwords from another source than the MASTER_PASSWORDS setting.

Release History

Release History

1.1.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_master_password-1.1.1-py2.py3-none-any.whl (10.9 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Aug 18, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting