Skip to main content

Django HTTP Basic Authentication Backend

Description

This module provides the client side for a HTTP Basic Authentication provider to allow authentication for a Django application. It must be installed as a Django authentication backend.

This allows to authenticate your Django application with the help of a web server that already provides HTTP Basic Authentication, as it is described in [RFC2617](https://www.ietf.org/rfc/rfc2617.txt). Web servers, such as Apache or Nginx, can easily be configured to adapt complex authentication scenarios, e.g. authentication via a combination of LDAP and manual filters. Your Django project is now able to utilize such a configuration.

Installation

Add this module to your setup.py and/or to requirements.txt file:

# … django-auth-http-basic # …

You need at least Django >= 1.10.

Configuration

In your settings.py file, you must add/set the variable AUTHENTICATION_BACKENDS so that it includes the authentication backend, e.g.:

AUTHENTICATION_BACKENDS = [‘django_auth_http_basic.HttpBasicAuthBackend’]

In addition, you must specify an URL that provides HTTP Basic Authentication by providing a value for the variable HTTP_BASIC_AUTH_URL in your settings.py file, e.g.:

HTTP_BASIC_AUTH_URL = ‘https://example.com/auth’

As long as the web services conforms to HTTP Basic Authentication, it could be used as an authentication backend. Since HTTP Basic Authentication transports user name and password in clear text, you should access it via HTTPS. If the web server is on your local host, you might use unencrypted HTTP.

The web server is expected to return a 401 response, if no user name and/or no password is provided. It must return a 2xx response if the user is authenticated, and a 403 response if the user is not authenticated. Currently, every response code except 2xx will be interpreted as a failed authentication. Most web servers conform to this rule. However, you are free to implement your own authenticating web server.

For testing purposes, HTTP_BASIC_AUTH_URL can be set to None. In this case no web server will be contacted, every user will be authenticated. Please be sure to change HTTP_BASIC_AUTH_URL to a valid URL for production code.

If you don’t set the variable HTTP_BASIC_AUTH_URL to any value, no user will be authenticated. In this case, an error message will be sent to the logger named django-auth-http-basic.

Another (optional) variable you can use in your settings.py is HTTP_BASIC_AUTH_CASE. This value specifies, whether the user name will be handled case-sensitive or case-insensitive in the backend. Its value itself is treated case-insensive. Only its first letter is analysed. If it is a ‘0’, ‘f’ or ‘n’, then the user name will be folded to lower-case. If you omit this variable, a value ‘yes’ is assumed.

Metadata

Release files for django-auth-http-basic 20191020.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-auth-http-basic 20191020.0
File Size Uploaded Provenance Actions
django-auth-http-basic-20191020.0.tar.gz 5.3 kB Without provenance Details for django-auth-http-basic-20191020.0.tar.gz

Release files / django-auth-http-basic-20191020.0.tar.gz

Download URL django-auth-http-basic-20191020.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6b2fe721b8da03b85fec0bd2ab12cb53a6cb372125e384e147f75ccfdb82de33
BLAKE2b-256 checksum
How to use checksums
1590b7306a7fae44fb8831b026eec10af18d7c5699c3d115fd6afae69e796a59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

Security for django-auth-http-basic 20191020.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page