Django SCIM 2.0 Service Provider

0.19.1 · active · verified Sat Apr 11

A partial implementation of the SCIM 2.0 provider specification for use with Django. It enables automatic provisioning and deprovisioning of user accounts and groups, facilitating identity synchronization across various identity providers and applications. The current stable version, as listed on PyPI, is 0.19.1, with development being stable and new releases occurring periodically, often focusing on Fridays.

Warnings

Install

Imports

Quickstart

To integrate `django-scim2`, add `django_scim` to `INSTALLED_APPS` and configure the `SCIM_SERVICE_PROVIDER` settings. Crucially, include `django_scim.urls` in your project's `urls.py` with the mandatory namespace `scim`. Note that as of version 0.18.0, the `SCIMAuthCheckMiddleware` is applied as a decorator to views, so it typically no longer needs to be added directly to the `MIDDLEWARE` setting. If you implement custom authentication, ensure it runs before SCIM processing.

import os

# settings.py example
INSTALLED_APPS = [
    # ... other Django apps
    'django_scim',
]

# Note: As of 0.18.0, SCIMAuthCheckMiddleware is applied as a decorator
# to SCIM views and typically no longer needs to be in MIDDLEWARE.
# If you need custom auth check middleware, specify it in SCIM_SERVICE_PROVIDER.
MIDDLEWARE = [
    # ... your authentication middleware (e.g., 'django.contrib.auth.middleware.AuthenticationMiddleware')
    # 'django_scim.middleware.SCIMAuthCheckMiddleware', # DEPRECATED: See warning for 0.18.0
    # Make sure your actual authentication middleware comes BEFORE this one if you add it directly.
    # The SCIMAuthCheckMiddleware checks request.user.is_anonymous() by default.
]

# Required SCIM settings
SCIM_SERVICE_PROVIDER = {
    'NETLOC': os.environ.get('SCIM_NETLOC', 'localhost:8000'), # E.g., 'your-domain.com'
    'AUTHENTICATION_SCHEMES': [
        {
            'type': 'oauth2',
            'name': 'OAuth 2',
            'description': 'OAuth 2 implemented with bearer token',
        },
    ],
    # Optional: Customize the authentication check middleware
    # 'AUTH_CHECK_MIDDLEWARE': 'your_app.middleware.CustomSCIMAuthMiddleware',
    # Optional: Expose SCIM exceptions to clients (defaults to False for security)
    # 'EXPOSE_SCIM_EXCEPTIONS': os.environ.get('SCIM_EXPOSE_EXCEPTIONS', False),
}

# urls.py example
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('scim/v2/', include('django_scim.urls')), # Namespace 'scim' is mandatory
]

view raw JSON →