Skip to main content

Handle login and ticket validation for french GAR

Project description

django-gar

Python 3.11 Django 4.x Python CI codecov Code style: black security: bandit

Django app to handle CAS authentication and resource management for the french Gestionnaire d'Accès aux Ressources (GAR).

Features

  • CAS authentication with GAR
  • Institution management with subscription tracking
  • Allocation monitoring for resources
  • Caching of GAR data (allocations, subscriptions, ENT IDs)
  • Admin interface for institution management
  • CSV export of allocation reports

Installation

Install with pip:

pip install django-gar

Setup

In order to make django-gar work, you'll need to follow these steps:

1. Settings

Add the required configuration to your settings:

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.messages',

    'django_gar',
    ...
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    
    'django_gar.middleware.GARMiddleware', # mandatory
    ...
)

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    
    'django_gar.backends.GARBackend',
    ...
)

2. Migrations

Run migrations to create the necessary database tables:

python manage.py migrate

3. Required Settings

Configure these mandatory settings:

# GAR Connection Settings
GAR_BASE_URL = "https://idp-auth.partenaire.test-gar.education.fr/"
GAR_BASE_SUBSCRIPTION_URL = "https://abonnement.partenaire.test-gar.education.fr/"
GAR_SUBSCRIPTION_PREFIX = "your_prefix"
GAR_DISTRIBUTOR_ID = "your_distributor_id"

# Authentication Certificates
GAR_CERTIFICATE_PATH = "/path/to/your/cert.pem"
GAR_KEY_PATH = "/path/to/your/key.pem"

# Resource Configuration
GAR_RESOURCES_ID = "your_resource_id"
GAR_ORGANIZATION_NAME = "Your Organization"

Optional settings with their defaults:

GAR_ACTIVE_USER_REDIRECT = "/"  # Redirect after successful login
GAR_INACTIVE_USER_REDIRECT = "/"  # Redirect for inactive users
GAR_QUERY_STRING_TRIGGER = "sso_id"  # URL parameter for SSO

Management Commands

refresh_gar_caches

Updates GAR data caches for institutions.

# Refresh all institutions
python manage.py refresh_gar_caches

# Refresh specific institution
python manage.py refresh_gar_caches --uai=0123456A

The command updates:

  • Resource allocation data
  • Subscription information

Use cases:

  • Initial setup of new institutions
  • Manual cache refresh
  • Troubleshooting GAR integration

refresh_gar_idents

Updates ENT IDs for all institutions from GAR.

python manage.py refresh_gar_idents

The command:

  • Fetches the latest institution list from GAR
  • Updates the ENT IDs (id_ent) for all matching institutions
  • Performs updates in bulk for better performance

Use cases:

  • Initial setup of new institutions
  • Bulk update of ENT IDs
  • Synchronizing with GAR institution list

Testing

Run tests with pytest:

# Install test dependencies
pip install -r test_requirements.txt

# Run tests
pytest

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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_gar-3.0.7.tar.gz (33.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_gar-3.0.7-py3-none-any.whl (33.3 kB view details)

Uploaded Python 3

File details

Details for the file django_gar-3.0.7.tar.gz.

File metadata

  • Download URL: django_gar-3.0.7.tar.gz
  • Upload date:
  • Size: 33.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for django_gar-3.0.7.tar.gz
Algorithm Hash digest
SHA256 5e2251107f45aec1568d1c615a5da1499fcb72c54b339ac2cbac7f017d1ab050
MD5 7c5bb214d65ae74a994e94d5c0bbc4ae
BLAKE2b-256 2b0f00baf376d90fac52a505e160c785532cc446473423800f7612fb6652c0c8

See more details on using hashes here.

File details

Details for the file django_gar-3.0.7-py3-none-any.whl.

File metadata

  • Download URL: django_gar-3.0.7-py3-none-any.whl
  • Upload date:
  • Size: 33.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for django_gar-3.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f0b6cbed857b3936f33661fee6c114099c380f93bbef77cbb6ea5e7facabfd2c
MD5 edd2cdaf0dd4c51de3bcba890940614a
BLAKE2b-256 0373b1b98a502c25cabcf480abae53d8a2f186ea9b7bd3e6cad4eff30edd32b8

See more details on using hashes here.

Supported by

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