From 5b77eeb0d694677cc1853799888533f07cf9ea7f Mon Sep 17 00:00:00 2001 From: Raphael Lullis Date: Mon, 27 Jan 2025 21:52:32 +0100 Subject: [PATCH] OIDC Session management (https://openid.net/specs/openid-connect-session-1_0.html) To enable it, user must add OIDC_SESSION_MANAGEMENT_ENABLED and provide OIDC_SESSION_MANAGEMENT_DEFAULT_SESSION_KEY on OAUTH2_PROVIDER settings, and add the proper middleware. This PR contains: - change in AuthorizationView to return 'session_state' parameter in authentication response - a SessionIFrameView as part of the OIDC views, which renders the content of the iframe used by RPs to keep track of session state changes. - middleware that sets the cookie - Documentation - Test for the changed authentication view --- AUTHORS | 1 + CHANGELOG.md | 1 + docs/oidc.rst | 33 ++++++++++ docs/settings.rst | 18 ++++++ oauth2_provider/checks.py | 13 ++++ oauth2_provider/middleware.py | 20 ++++++ oauth2_provider/settings.py | 4 ++ .../templates/oauth2_provider/base.html | 2 + .../oauth2_provider/check_session_iframe.html | 63 +++++++++++++++++++ oauth2_provider/urls.py | 1 + oauth2_provider/utils.py | 11 ++++ oauth2_provider/views/__init__.py | 8 ++- oauth2_provider/views/base.py | 36 +++++++++-- oauth2_provider/views/oidc.py | 39 +++++++++--- tests/presets.py | 4 ++ tests/test_oidc_views.py | 50 ++++++++++++++- tests/test_session_management.py | 46 ++++++++++++++ 17 files changed, 335 insertions(+), 15 deletions(-) create mode 100644 oauth2_provider/templates/oauth2_provider/check_session_iframe.html create mode 100644 tests/test_session_management.py diff --git a/AUTHORS b/AUTHORS index e2da60020..6b9632b18 100644 --- a/AUTHORS +++ b/AUTHORS @@ -99,6 +99,7 @@ Peter Karman Peter McDonald Petr DlouhĂ˝ pySilver +Raphael Lullis Rodney Richardson Rustem Saiargaliev Rustem Saiargaliev diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c4770459..cae4b0deb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] ### Added * #1506 Support for Wildcard Origin and Redirect URIs +* Support for OIDC Session Management (https://openid.net/specs/openid-connect-session-1_0.html)