From 77e5bbd620b218622ffa2bfd2295754b5067a844 Mon Sep 17 00:00:00 2001 From: Gregor Grigorjan Date: Sat, 27 Apr 2024 14:17:37 +0300 Subject: [PATCH 1/5] chore(test): bump `django-allauth`: 0.61.1 -> 0.62.1 --- dj_rest_auth/tests/requirements.pip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dj_rest_auth/tests/requirements.pip b/dj_rest_auth/tests/requirements.pip index 214895e..16084f7 100644 --- a/dj_rest_auth/tests/requirements.pip +++ b/dj_rest_auth/tests/requirements.pip @@ -1,5 +1,5 @@ coveralls==1.11.1 -django-allauth==0.61.1 +django-allauth[socialaccount]==0.62.1 djangorestframework-simplejwt>=5.3.1 flake8==3.8.4 responses==0.12.1 From cfaa9f6a7bda8eff085af147663601d0e6b99d33 Mon Sep 17 00:00:00 2001 From: Gregor Grigorjan Date: Sat, 27 Apr 2024 14:18:19 +0300 Subject: [PATCH 2/5] fix(test): breakage with `django-allauth` 0.62.1 --- dj_rest_auth/tests/test_serializers.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dj_rest_auth/tests/test_serializers.py b/dj_rest_auth/tests/test_serializers.py index 74f9281..9e86cf9 100644 --- a/dj_rest_auth/tests/test_serializers.py +++ b/dj_rest_auth/tests/test_serializers.py @@ -1,6 +1,6 @@ from allauth.socialaccount.providers.facebook.views import FacebookOAuth2Adapter -from allauth.socialaccount.providers.facebook.views import FacebookProvider +from allauth.socialaccount.providers.facebook.provider import FacebookProvider from allauth.socialaccount.models import SocialApp from allauth.core.exceptions import ImmediateHttpResponse from django.contrib.auth import get_user_model @@ -8,6 +8,7 @@ from django.core.exceptions import ValidationError from django.test import TestCase, modify_settings, override_settings from django.contrib.sites.models import Site +from django.contrib.sessions.middleware import SessionMiddleware from django.http import HttpResponseBadRequest from rest_framework.exceptions import ErrorDetail from rest_framework.test import APIRequestFactory, force_authenticate @@ -119,6 +120,10 @@ class TestSocialLoginSerializer(TestCase): def setUpTestData(cls): cls.request_data = {"access_token": "token1234"} cls.request = APIRequestFactory().post(cls.request_data, format='json') + + middleware = SessionMiddleware(get_response=MagicMock()) + middleware(cls.request) + social_app = SocialApp.objects.create( provider='facebook', name='Facebook', @@ -148,7 +153,7 @@ def test_validate_no_adpapter_class_present(self): serializer.is_valid() self.assertDictEqual(serializer.errors, self.NO_ADAPTER_CLASS_PRESENT) - @patch('allauth.socialaccount.providers.facebook.views.fb_complete_login') + @patch('allauth.socialaccount.providers.facebook.views.FacebookOAuth2Adapter.complete_login') @patch('allauth.socialaccount.adapter.DefaultSocialAccountAdapter.pre_social_login') def test_immediate_http_response_error(self, mock_pre_social_login, mock_fb_complete_login): dummy_view = SocialLoginView() From 3342e05f1d4f01dc97d08afc8ba7acaff969e3f1 Mon Sep 17 00:00:00 2001 From: Raymond Penners Date: Thu, 25 Apr 2024 23:21:33 +0200 Subject: [PATCH 3/5] feat: Upgrade django-allauth --- dj_rest_auth/registration/serializers.py | 2 +- dj_rest_auth/tests/test_serializers.py | 7 ++----- setup.py | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/dj_rest_auth/registration/serializers.py b/dj_rest_auth/registration/serializers.py index db095cf..eef0bfb 100644 --- a/dj_rest_auth/registration/serializers.py +++ b/dj_rest_auth/registration/serializers.py @@ -119,7 +119,7 @@ def validate(self, attrs): ) provider = adapter.get_provider() - scope = provider.get_scope(request) + scope = provider.get_scope_from_request(request) client = self.client_class( request, app.client_id, diff --git a/dj_rest_auth/tests/test_serializers.py b/dj_rest_auth/tests/test_serializers.py index 9e86cf9..f89f7b7 100644 --- a/dj_rest_auth/tests/test_serializers.py +++ b/dj_rest_auth/tests/test_serializers.py @@ -120,10 +120,7 @@ class TestSocialLoginSerializer(TestCase): def setUpTestData(cls): cls.request_data = {"access_token": "token1234"} cls.request = APIRequestFactory().post(cls.request_data, format='json') - - middleware = SessionMiddleware(get_response=MagicMock()) - middleware(cls.request) - + cls.request.session = {} social_app = SocialApp.objects.create( provider='facebook', name='Facebook', @@ -153,7 +150,7 @@ def test_validate_no_adpapter_class_present(self): serializer.is_valid() self.assertDictEqual(serializer.errors, self.NO_ADAPTER_CLASS_PRESENT) - @patch('allauth.socialaccount.providers.facebook.views.FacebookOAuth2Adapter.complete_login') + @patch('allauth.socialaccount.providers.facebook.flows.complete_login') @patch('allauth.socialaccount.adapter.DefaultSocialAccountAdapter.pre_social_login') def test_immediate_http_response_error(self, mock_pre_social_login, mock_fb_complete_login): dummy_view = SocialLoginView() diff --git a/setup.py b/setup.py index 91f50c4..a0843bf 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ 'djangorestframework>=3.13.0', ], extras_require={ - 'with_social': ['django-allauth>=0.56.0,<0.62.0'], + 'with_social': ['django-allauth[socialaccount]>=0.62.0,<=0.62.1'], }, tests_require=[ 'coveralls>=1.11.1', From 7eb2ec914a4c76d6699c15f8fb9499ae88bbcc66 Mon Sep 17 00:00:00 2001 From: Raymond Penners Date: Thu, 2 May 2024 18:57:48 +0200 Subject: [PATCH 4/5] fix: Handle client signature change --- dj_rest_auth/registration/serializers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/dj_rest_auth/registration/serializers.py b/dj_rest_auth/registration/serializers.py index eef0bfb..f5453a2 100644 --- a/dj_rest_auth/registration/serializers.py +++ b/dj_rest_auth/registration/serializers.py @@ -127,7 +127,6 @@ def validate(self, attrs): adapter.access_token_method, adapter.access_token_url, self.callback_url, - scope, scope_delimiter=adapter.scope_delimiter, headers=adapter.headers, basic_auth=adapter.basic_auth, From 2ebf734ea3d8c549981beb1142d1a268d27d7c2c Mon Sep 17 00:00:00 2001 From: "@iMerica" Date: Sun, 7 Jul 2024 17:35:02 -0500 Subject: [PATCH 5/5] Fixes unused vars --- dj_rest_auth/registration/serializers.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/dj_rest_auth/registration/serializers.py b/dj_rest_auth/registration/serializers.py index f5453a2..416de96 100644 --- a/dj_rest_auth/registration/serializers.py +++ b/dj_rest_auth/registration/serializers.py @@ -118,8 +118,6 @@ def validate(self, attrs): _('Define client_class in view'), ) - provider = adapter.get_provider() - scope = provider.get_scope_from_request(request) client = self.client_class( request, app.client_id,