Handle CAS login via sso for french libraries (C3RB, GMInvent and Archimed).
Install with pip:
pip install -e git://github.com/briefmnews/django-library.git@main#egg=django-library
In order to make django-library
works, you'll need to follow the steps below.
First you need to add the following configuration to your settings:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.messages',
'django_library',
...
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django_library.middleware.CASMiddleware',
...
)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'django_library.backends.CASBackend',
...
)
Next, you need to run the migrations in order to update your database schema.
python manage.py migrate
Here is the list of all the mandatory settings:
LIBRARY_GMINVENT_BASE_URL
LIBRARY_C3RB_BASE_URL
LIBRARY_ARCHIMED_BASE_URL
LIBRARY_QUERY_STRING_TRIGGER
You can set a default path redirection for inactive user by adding this line to your settings:
LIBRARY_INACTIVE_USER_REDIRECT = '/{mycustompath}/'
LIBRARY_INACTIVE_USER_REDIRECT
is used if an inactive user with a valid ticket
tries to login.
If LIBRARY_INACTIVE_USER_REDIRECT
is not set in the settings, it will take
the root path (i.e. /
) as default value.
Once your all set up, when a request to your app is made with the query string
library_sso_id=<unique_sso_id>
, the CASMiddleware
catches the request and start the login process.
Here is an example of a request url to start the login process:
https://www.exemple.com/?library_sso_id=briefme
Testing is managed by pytest
. Required package for testing can be installed with:
pip install -r test_requirements.txt
To run testing locally:
pytest