Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Middleware for using Shibboleth with Django
branch: master
Failed to load latest commit information.
shibboleth Fix typo in REMOTE_USER.
.gitignore Ignoring venv.
.travis.yml Test Django 1.5 and 1.6. Update Create Adding ROOT_URLCONF for tests with Django 1.4


Middleware for using Shibboleth with Django. Requires Django 1.3 or above for RemoteAuthMiddleware.

Build Status

Installation and configuration

  • Either checkout and run python install or install directly from Github with pip:

    pip install git+
  • In :

    • Enable the RemoteUserBackend.

    • Add the Django Shibboleth middleware. You must add the django.contrib.auth.middleware.ShibbolethRemoteUserMiddleware to the MIDDLEWARE_CLASSES setting after the django.contrib.auth.middleware.AuthenticationMiddleware. For example:

    • Map Shibboleth attributes to Django User models. The attributes must be stated in the form they have in the HTTP headers. Use this to populate the Django User object from Shibboleth attributes.

      The first element of the tuple states if the attribute is required or not. If a reqired element is not found in the parsed Shibboleth headers, an exception will be raised. (True, "required_attribute") (False, "optional_attribute).

         "shib-user": (True, "username"),
         "shib-given-name": (True, "first_name"),
         "shib-sn": (True, "last_name"),
         "shib-mail": (False, "email"),
    • Login url - set this to the login handler of your shibboleth installation. In most cases, this will be something like:

    LOGIN_URL = ''
  • Apache configuration - make sure the shibboleth attributes are available to the app. The app url doesn't need to require Shibboleth.

    <Location /app>
      AuthType shibboleth
      Require shibboleth

Verify configuration

If you would like to verify that everything is configured correctly, follow the next two steps below. It will create a route in your application at /yourapp/shib/ that echos the attributes obtained from Shibboleth. If you see the attributes you mapped above on the screen, all is good.

  • Add shibboleth to installed apps.

  • Add below to to enable the included sample view. This view just echos back the parsed user attributes, which can be helpful for testing.

    urlpatterns += patterns('',
      url(r'^shib/', include('shibboleth.urls', namespace='shibboleth')),

At this point, the django-shibboleth-remoteuser middleware should be complete.


Template tags

  • Template tags are included which will allow you to place {{ login_link }} or {{ logout_link }} in your templates for routing users to the login or logout page. These are available as a convenience and not required. To activate add the following to

Something went wrong with that request. Please try again.