Skip to main content

GSSAPI authentication for Django

Project description

GSSAPI authentication for Django

Provide GSSAPI (SPNEGO) authentication to Django applications.

It’s a rewrite of django-kerberos using python-gssapi.

It’s only tested with MIT Kerberos 5 using package k5test.

Python 2 and 3, Django >1.8 are supported.

Basic usage

Add this to your project urls.py:

url('^auth/gssapi/', include('django_gssapi.urls')),

And use the default authentication backend, by adding that to your settings.py file:

AUTHENTICATION_BACKENDS = (
    'django_gssapi.backends.GSSAPIBackend',
)

View

django-gssapi provide a base LoginView that you can subclass to get the behaviour your need, the main extension points are:

  • challenge() returns the 401 response with the challenge, you should override it to show a template explaining the failure,

  • success(user) it should log the given user and redirect to REDIRECT_FIELD_NAME,

  • get_service_name() it should return a gssapi.Name for your service, by default it returns None, so GSSAPI will match any name available (for example with Kerberos it will match any name in your keytab, like @HTTP/my.domain.com@).

Settings

To make your application use GSSAPI as its main login method:

LOGIN_URL = 'gssapi-login'

Your application need an environment where the GSSAPI mechanism like Kerberos will work, for Kerberos it means having a default keytab of creating one and setting its path in KRB5_KTNAME or you can use GSSAPI_STORE with MIT Kerberos 5 and credential store extension to indicate a keytab:

GSSAPI_STORE = {'keytab': 'FILE:/var/lib/mykeytab'}

You can also force a GSSAPI name for you service with:

import gssapi

GSSAPI_NAME = gssapi.Name('HTTP/my.service.com', gssapi.MechType.hostbased_service)

GSSAPI authentication backend

A dummy backend is provided in django_gssapi.backends.GSSAPIBackend it looks up user with the same username as the GSSAPI name. You should implement it for your use case.

A custom authentication backend must have the following signature:

class CustomGSSAPIBackend(object):
    def authenticate(self, request, gssapi_name):
        pass

The parameter gssapi_name is a gssapi.Name object, it can be casted to string to get the raw name.

Kerberos username/password backend

If your users does not have their browser configured for SPNEGO HTTP authentication you can also provide a classic login/password form which check passwords using Kerberos. For this use django_gssapi.backends.KerberosPasswordBackend, the username is used as the raw principal name.

django-rest-framework authentication backend

To authenticate users with GSSAPI you can use django_gssapi.drf.GSSAPIAuthentication, it uses the configured GSSAPI authentication backend to find an user and returns the GSSAPI name in request.auth.

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

django-gssapi-0.9b3.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

django_gssapi-0.9b3-py2.py3-none-any.whl (9.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-gssapi-0.9b3.tar.gz.

File metadata

  • Download URL: django-gssapi-0.9b3.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.16+

File hashes

Hashes for django-gssapi-0.9b3.tar.gz
Algorithm Hash digest
SHA256 403faa82795cb8c5cbd52f14cfdc27731fe64c124c0a483f5eafc81825f64ad6
MD5 4cf3f33ffc9c27dea90a337370aec7fb
BLAKE2b-256 ea7fa0d1d6dc0b07b0f5fb71937e6cdf97665862a5d48421cdafcc426d23f7b3

See more details on using hashes here.

File details

Details for the file django_gssapi-0.9b3-py2.py3-none-any.whl.

File metadata

  • Download URL: django_gssapi-0.9b3-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.16+

File hashes

Hashes for django_gssapi-0.9b3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6ee594c94f542dd86193f22cc2a3f07070f9633d8fb9eb69b02ac5bed7427fa4
MD5 c18d172e122d3d8807390d027e79e7c3
BLAKE2b-256 84445cc26b48ffb2dd0d8e1a97deed15ed61df629ccddadbe19003b87dee9e16

See more details on using hashes here.

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