Skip to content

Commit

Permalink
update module documentation for django integration
Browse files Browse the repository at this point in the history
  • Loading branch information
lilioid committed Dec 26, 2024
1 parent fd2564c commit f4571cb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
33 changes: 33 additions & 0 deletions src/simple_openid_connect/integrations/django/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
"""
Django integration for :mod:`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:
.. code-block:: text
┌──────────────────────────────────┐ ┌──────────────────────────────────┐ ┌───────────────────┐
│ @access_token_required decorator │ │ DRF AccessTokenAuthentication │ │ LoginCallbackView │
└────────────────┬─────────────────┘ └─────────────────┬────────────────┘ └─────────┬─────────┘
│ │ │
└───────────────────┬───────────────────┘ │
↓ │
┌──────────────────────┴─────────────────────┐ │
│ UserMapper.handle_federated_access_token() │ │
└──────────────────────┬─────────────────────┘ │
│ │
└──────────────────────────┬───────────────────────┘
┌────────────────────┴───────────────────┐
│ UserMapper.handle_federated_userinfo() │
└────────────────────┬───────────────────┘
┌────────────────┴────────────────┐
│ UserMapper.automap_user_attrs() │
└─────────────────────────────────┘
- :class:`InitLoginView <simple_openid_connect.integrations.django.views.InitLoginView>` & :class:`LoginCallbackView <simple_openid_connect.integrations.django.views.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.
- :class:`UserMapper <simple_openid_connect.integrations.django.user_mapping.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.
"""
24 changes: 0 additions & 24 deletions src/simple_openid_connect/integrations/django/user_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,6 @@
class UserMapper:
"""
A base class which is responsible for mapping federated users into the local system.
This class is used in different parts of *simple_openid_connect* and the callgraph is sketched below:
.. code-block:: text
┌──────────────────────────────────┐ ┌──────────────────────────────────┐ ┌───────────────────┐
│ @access_token_required decorator │ │ DRF AccessTokenAuthentication │ │ LoginCallbackView │
└────────────────┬─────────────────┘ └─────────────────┬────────────────┘ └─────────┬─────────┘
│ │ │
└───────────────────┬───────────────────┘ │
↓ │
┌──────────────────────┴─────────────────────┐ │
│ UserMapper.handle_federated_access_token() │ │
└──────────────────────┬─────────────────────┘ │
│ │
└──────────────────────────┬───────────────────────┘
┌────────────────────┴───────────────────┐
│ UserMapper.handle_federated_userinfo() │
└────────────────────┬───────────────────┘
┌────────────────┴────────────────┐
│ UserMapper.automap_user_attrs() │
└─────────────────────────────────┘
"""

def handle_federated_userinfo(self, user_data: FederatedUserData) -> Any:
Expand Down

0 comments on commit f4571cb

Please sign in to comment.