simple_openid_connect.integrations.django

Django integration for simple_openid_connect.

Architecture

Integrating a new authentication mechanism into django involves a few missing parts. Here’s a quick overview over the most important classes involved:

┌──────────────────────────────────┐   ┌──────────────────────────────────┐   ┌───────────────────┐
│ @access_token_required decorator │   │ DRF AccessTokenAuthentication    │   │ LoginCallbackView │
└────────────────┬─────────────────┘   └─────────────────┬────────────────┘   └─────────┬─────────┘
                 │                                       │                              │
                 └───────────────────┬───────────────────┘                              │
                                     ↓                                                  │
              ┌──────────────────────┴─────────────────────┐                            │
              │ UserMapper.handle_federated_access_token() │                            │
              └──────────────────────┬─────────────────────┘                            │
                                     │                                                  │
                                     └──────────────────────────┬───────────────────────┘
                                                                ↓
                                           ┌────────────────────┴───────────────────┐
                                           │ UserMapper.handle_federated_userinfo() │
                                           └────────────────────┬───────────────────┘
                                                                ↓
                                               ┌────────────────┴────────────────┐
                                               │ UserMapper.automap_user_attrs() │
                                               └─────────────────────────────────┘
  • InitLoginView & LoginCallbackView are the backing views behind …/login/ and …/login-callback/. They implement authentication initiation with an OIDC provider and then handle the response to it in the callback.

  • UserMapper creates a local user account based on OIDC data and keeps it up to date. It is called every time a user authenticates, which is the case during interactive authentication as well as when a user passes an access token to e.g. an API route.

Modules

apps

Django AppConfig for this app

decorators

View-function decorators

middleware

migrations

models

simple_openid_connect database models

settings

Django settings for simple_openid_connect project so that migrations can properly be generated

urls

simple_openid_connect URL Configuration

user_mapping

Default implementations for mapping tokens to user objects.

views

View functions which handle openid authentication and their related callbacks

wsgi

WSGI config for simple_openid_connect project.