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.

Source Distribution

dj-authentication-0.1.1.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

dj_authentication-0.1.1-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page