Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Nice HTTP authentication support for Django

Project description

Nice HTTP authentication support for Django

This is a common base for supporting multiple auth methods in an app.

Right now, we provide only the HTTP Basic auth module; but you can easily add your own specific schemes, if you need them, and more generic ones are going to be added in the future (see Planned features).


  • Django 2.0+


pip install dj-authentication

  • Add 'dj_authentication' to the list of INSTALLED_APPS.
  • Remove 'django.contrib.auth.middleware.AuthenticationMiddleware' from the list of MIDDLEWAREs.
  • Add dj_authentication.request_http_auth.HTTPAuthMiddleware to the list of MIDDLEWAREs.
  • Choose backends used for determining request.user, for example:
    'dj_authentication.methods.basic', # HTTP Basic Auth


To trigger an authentication dialog in a browser, if the user is not authenticated:

if not request.user.is_authenticated:
    return HttpResponse(status=401)

Note: this requires dj_authentication.methods.basic backend.

Planned features

Project details

Download files

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

Files for dj-authentication, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size dj_authentication-0.1.0-py3-none-any.whl (5.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size dj-authentication-0.1.0.tar.gz (4.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page