Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Basic auth utilities for Django.

Project Description

Basic auth utilities for Django.

Requires

Tested under…

  • Python
    • 2.7
    • 3.6
  • Django
    • 1.8
    • 1.10
    • 1.11

Installation

pip install django-basicauth

Usage

from basicauth.decorators import basic_auth_required

@basic_auth_required
def myview(request):
    ...

or by a middleware.

MIDDLEWARE_CLASSES = (
    'basicauth.middleware.BasicAuthMiddleware',
    ...
)

Basic Auth for specific requestno only

To apply basic auth for specific requests, Use target_test argument.

In the below code, anonymous users will be required Basic Auth Authenticated users can pass it without Basic ... header.

from basicauth.decorators import basic_auth_required

@basic_auth_required(
    target_test=lambda request: not request.is_authenticated
)
def myview(request):
    ...

target_test accepts typing.Callable[[HttpRequest], bool], and if the callable returns True, Basic Auth will be required.

Settings

  • BASICAUTH_USERS (required): Dictionary including keys as username and values as passwords.
  • BASICAUTH_REALM: realm string, default is “Secure resource”.
  • BASICAUTH_DISABLE: Disable all of barriers by this library.

Changes

0.4.1 (2017-10-20)

  • Added target_test argument for the decorator.

0.4 (2017-09-30)

  • Supported Python 2.7
  • Dropped Django1.9
  • Supported Django 1.10+ style middleware

0.3 (2017-08-28)

  • Added BASICAUTH_DISABLE setting
  • Changed API of basicauthutils.validate_request
    • Fixed to return True/False
    • Adding REMOTE_USER by this function

0.2.1 (2017-08-28)

  • Officially supported Django 1.11, 1.10, 1.9

0.2 (2016-03-31)

0.1 (2015-04-20)

  • Initial
Release History

Release History

This version
History Node

0.4.1

History Node

0.4

History Node

0.3

History Node

0.2.1

History Node

0.2

History Node

0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_basicauth-0.4.1-py3-none-any.whl (6.2 kB) Copy SHA256 Checksum SHA256 3.5 Wheel Oct 20, 2017
django-basicauth-0.4.1.tar.gz (4.6 kB) Copy SHA256 Checksum SHA256 Source Oct 20, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS 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