Skip to main content

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.

Metadata

Release files for django-gar 4.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-gar 4.4.0
File Size Uploaded
django_gar-4.4.0.tar.gz 35.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-gar 4.4.0
File Interpreter ABI Platform
django_gar-4.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 69.8 kB

Release files / django_gar-4.4.0.tar.gz

Download URL django_gar-4.4.0.tar.gz
Size 35.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4b2c8ef7d277a00071d900c3fe36a4c7dcaed3b551b9aac5418cf24b91eb11ba
BLAKE2b-256 checksum
How to use checksums
df035fbed4feb8464b7897fadc1c76ccf101bad0a05ed27a3ed1493de759f655
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Release files / django_gar-4.4.0-py3-none-any.whl

Download URL django_gar-4.4.0-py3-none-any.whl
Size 34.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3dbc1b49fb8312a015f6090e86b737fc910477cecaacff179668cecd4d855563
BLAKE2b-256 checksum
How to use checksums
dc8d1a4427abfaf436edfa3889df897be382c20b3bafeffd1c19edb38ae56c5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Release history Release notifications | RSS feed

4.4.1

2 release files

This release

4.4.0 This release

2 release files

4.3.4

2 release files

4.3.3

2 release files

4.3.2

2 release files

4.3.1

2 release files

4.2.2

2 release files

4.2.1

2 release files

4.2.0

2 release files

4.1.0

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.7

2 release files

3.0.6

2 release files

3.0.5

2 release files

3.0.4

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.16.1

2 release files

2.16.0

2 release files

2.15.0

2 release files

2.14.0

2 release files

2.13.1

2 release files

2.13.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page