Skip to main content

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).

Requirements

  • Django 2.0+

Installation

pip install dj-authentication

settings.py

  • 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:
REQUEST_USER_BACKENDS = [
    'dj_authentication.methods.basic', # HTTP Basic Auth
    'django.contrib.auth',
]

Tips

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.1
Filename, size File type Python version Upload date Hashes
Filename, size dj_authentication-0.1.1-py3-none-any.whl (6.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size dj-authentication-0.1.1.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page