django-shibauth-rit 1.1.0

Creator: codyrutscher

Last updated:

Add to Cart

Description:

djangoshibauthrit 1.1.0

=============================Django Shib Auth RIT=============================.. image:: https://badge.fury.io/py/django-shibauth-rit.svg :target: https://badge.fury.io/py/django-shibauth-rit.. image:: https://travis-ci.org/audiolion/django-shibauth-rit.svg?branch=master :target: https://travis-ci.org/audiolion/django-shibauth-rit.. image:: https://codecov.io/gh/audiolion/django-shibauth-rit/branch/master/graph/badge.svg :target: https://codecov.io/gh/audiolion/django-shibauth-ritIntegrate Shibboleth Authentication with your RIT projectsQuickstart----------Install Django Shib Auth RIT:: pip install django-shibauth-ritAdd it to your `INSTALLED_APPS`:.. code-block:: python INSTALLED_APPS = ( ... 'shibauth_rit', ... )Add the authentication backend:.. code-block:: python AUTHENTICATION_BACKENDS = [ 'shibauth_rit.backends.ShibauthRitBackend', ... ]Add the middleware to process requests:.. code-block:: python # use MIDDLEWARE_CLASSES on Django 1.8 MIDDLEWARE = ( ... 'django.contrib.auth.middleware.AuthenticationMiddleware', 'shibauth_rit.middleware.ShibauthRitMiddleware', ... )Add Django Shib Auth RIT's URL patterns:.. code-block:: python urlpatterns = [ ... url(r'^', include('shibauth_rit.urls')), ... ]Set the `LOGIN_URL` setting to the login handler of RIT's Shibboleth installation:.. code-block:: python LOGIN_URL = 'https://<your-site-root>/Shibboleth.sso/Login'Map Shibboleth's return attributes to your user model:.. code-block:: python SHIBAUTH_ATTRIBUTE_MAP = { 'uid': (True, 'username'), 'mail': (False, 'email'), }Shibboleth returns a number of attributes after a successful authentication. According to RIT'sdocs the current attributes returned are:.. code-block:: uid - the user's RIT username givenName - the user's given (first) name sn -the user's surname (last/family name) mail - the user's email address (note that this can be null) ritEduMemberOfUid - groups the account is a member of (Ex: forklift-operators, vendingmach-admins, historyintegrator, etc.) ritEduAffiliation - multi-valued attribute showing relationship to RIT (Ex: Student, Staff, StudentWorker, Adjust, Retiree etc.)Note: Additional attributes can be configured on a site-by-site basis. Please contact the ITS Service Desk with requests for additional attributes.When you map attributes, you use a Tuple of `(Boolean, 'UserModelField')` where `Boolean` indicates if the field is `REQUIRED`. This should match yourUser model's requirements. If your User model is as follow:.. code-block:: python class User(AbstractBaseUser, PermissionsMixin): USERNAME_FIELD = 'email' EMAIL_FIELD = 'email' email = models.EmailField(_('email address'), unique=True, blank=True, null=True) username = models.CharField(_('username'), unique=True, required=True, max_length=50) name = models.CharField(_('Name of User'), blank=True, max_length=100)Then `username` is a required attribute and should be `'uid': (True, 'username')` but email is notrequired and should be `'mail': (False, 'email')`.Note: If email is a required field on your model, shibboleth doesn't guarantee that `mail` will be populated so you will need to handle that exception. You can do this by subclassing `ShibauthRitBackend` and overriding `handle_parse_exception()` method. See [Subclassing ShibauthRitBackend]()..htaccess Setup---------------This package requires your site to be hosted on RIT's servers. The .htaccess should look like this.. code-block:: apache # Ensure https is on. required for shibboleth auth RewriteCond You can't use 'macro parameter character #' in math modeYou can't use 'macro parameter character #' in math mode python runtests.pyTo comprehensively test the suite across versions of python and django.. code-block:: bash source <YOURVIRTUALENV>/bin/activate (myenv) pipinstalltox(myenv) toxCredits-------Tools used in rendering this package:* Cookiecutter_* `cookiecutter-djangopackage`_.. _Cookiecutter: https://github.com/audreyr/cookiecutter.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackageHistory-------0.1.0 (2017-02-15)++++++++++++++++++* First release on PyPI.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.