From 0220875c703ffa9dc027cb49a02501a0fe77500b Mon Sep 17 00:00:00 2001 From: Quentin BEY Date: Thu, 10 Apr 2025 14:50:38 +0200 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F(django-lasuite)=20bump=20to?= =?UTF-8?q?=20version=200.0.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bump the lib to the latest version: - update the post_get_or_create_user method signature - allow silent login for OIDC (will require frontend implementation) --- src/backend/core/authentication/backends.py | 3 ++- src/backend/core/tests/authentication/test_backends.py | 2 +- src/backend/people/settings.py | 3 +++ src/backend/pyproject.toml | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/backend/core/authentication/backends.py b/src/backend/core/authentication/backends.py index 4df8074..8ea0a76 100644 --- a/src/backend/core/authentication/backends.py +++ b/src/backend/core/authentication/backends.py @@ -49,13 +49,14 @@ class OIDCAuthenticationBackend(LaSuiteOIDCAuthenticationBackend): ) return extra_claims - def post_get_or_create_user(self, user, claims): + def post_get_or_create_user(self, user, claims, is_new_user): """ Post-processing after user creation or retrieval. Args: user (User): The user instance. claims (dict): The claims dictionary. + is_new_user (bool): Indicates if the user was newly created. Returns: - None diff --git a/src/backend/core/tests/authentication/test_backends.py b/src/backend/core/tests/authentication/test_backends.py index 32b98de..a66a060 100644 --- a/src/backend/core/tests/authentication/test_backends.py +++ b/src/backend/core/tests/authentication/test_backends.py @@ -257,7 +257,7 @@ def test_models_oidc_user_getter_invalid_token(django_assert_num_queries, monkey django_assert_num_queries(0), pytest.raises( SuspiciousOperation, - match="User info contained no recognizable user identification", + match="Claims verification failed", ), ): klass.get_or_create_user(access_token="test-token", id_token=None, payload=None) diff --git a/src/backend/people/settings.py b/src/backend/people/settings.py index 4670a03..ad66d7b 100755 --- a/src/backend/people/settings.py +++ b/src/backend/people/settings.py @@ -392,6 +392,9 @@ class Base(Configuration): } # OIDC - Authorization Code Flow + OIDC_AUTHENTICATE_CLASS = "lasuite.oidc_login.views.OIDCAuthenticationRequestView" + OIDC_CALLBACK_CLASS = "lasuite.oidc_login.views.OIDCAuthenticationCallbackView" + OIDC_CREATE_USER = values.BooleanValue( default=True, environ_name="OIDC_CREATE_USER", diff --git a/src/backend/pyproject.toml b/src/backend/pyproject.toml index 7993f84..2e335b9 100644 --- a/src/backend/pyproject.toml +++ b/src/backend/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ "django-configurations==2.5.1", "django-cors-headers==4.7.0", "django-countries==7.6.1", - "django-lasuite==0.0.2", + "django-lasuite==0.0.5", "django-oauth-toolkit==3.0.1", "django-parler==2.3", "django-redis==5.4.0",