Răsfoiți Sursa

Closes #23661: Upgrade to social-auth-core 7.3.0

Move to social-auth-core 7.3.0 and social-auth-app-django 8.2.0, which
must be upgraded together, and drop the upper-bound caps. The tests now
use a surviving exception class in place of the removed AuthFailed and
check the per-transaction OAuth2 state stored in the session. The
display entry for the docker backend, removed upstream, is dropped.
Jason Novinger 2 zile în urmă
părinte
comite
0de49d43b8

+ 2 - 2
base_requirements.txt

@@ -152,11 +152,11 @@ rq<3.0
 
 
 # Django app for social-auth-core
 # Django app for social-auth-core
 # https://github.com/python-social-auth/social-app-django/blob/master/CHANGELOG.md
 # https://github.com/python-social-auth/social-app-django/blob/master/CHANGELOG.md
-social-auth-app-django<7.0.0
+social-auth-app-django
 
 
 # Social authentication framework
 # Social authentication framework
 # https://github.com/python-social-auth/social-core/blob/master/CHANGELOG.md
 # https://github.com/python-social-auth/social-core/blob/master/CHANGELOG.md
-social-auth-core<6.0.0
+social-auth-core
 
 
 # Image thumbnail generation
 # Image thumbnail generation
 # https://github.com/mariocesar/sorl-thumbnail/blob/main/CHANGES.rst
 # https://github.com/mariocesar/sorl-thumbnail/blob/main/CHANGES.rst

+ 0 - 1
netbox/netbox/authentication/__init__.py

@@ -33,7 +33,6 @@ AUTH_BACKEND_ATTRS = {
     'bitbucket': ('BitBucket', 'bitbucket'),
     'bitbucket': ('BitBucket', 'bitbucket'),
     'bitbucket-oauth2': ('BitBucket', 'bitbucket'),
     'bitbucket-oauth2': ('BitBucket', 'bitbucket'),
     'digitalocean': ('DigitalOcean', 'digital-ocean'),
     'digitalocean': ('DigitalOcean', 'digital-ocean'),
-    'docker': ('Docker', 'docker'),
     'github': ('GitHub', 'github'),
     'github': ('GitHub', 'github'),
     'github-app': ('GitHub', 'github'),
     'github-app': ('GitHub', 'github'),
     'github-org': ('GitHub', 'github'),
     'github-org': ('GitHub', 'github'),

+ 7 - 5
netbox/netbox/tests/test_authentication.py

@@ -4,6 +4,7 @@ import re
 import sys
 import sys
 from types import ModuleType
 from types import ModuleType
 from unittest.mock import MagicMock, patch
 from unittest.mock import MagicMock, patch
+from urllib.parse import parse_qs, urlsplit
 
 
 from django.conf import settings
 from django.conf import settings
 from django.contrib.messages.storage.fallback import FallbackStorage
 from django.contrib.messages.storage.fallback import FallbackStorage
@@ -15,7 +16,7 @@ from django.urls import reverse
 from django.utils.timezone import now
 from django.utils.timezone import now
 from rest_framework.test import APIClient
 from rest_framework.test import APIClient
 from social_core.backends.base import BaseAuth
 from social_core.backends.base import BaseAuth
-from social_core.exceptions import AuthFailed
+from social_core.exceptions import AuthResponseError
 from social_django.models import UserSocialAuth
 from social_django.models import UserSocialAuth
 
 
 from account.views import LoginView
 from account.views import LoginView
@@ -1144,8 +1145,9 @@ class SocialAuthBeginViewTestCase(DjangoTestCase):
         """
         """
         response = self.client.post(self.url, headers={'accept': 'application/json'})
         response = self.client.post(self.url, headers={'accept': 'application/json'})
 
 
-        state = self.client.session['google-oauth2_state']
-        self.assertIn(f'state={state}', response.json()['url'])
+        state = parse_qs(urlsplit(response.json()['url']).query)['state'][0]
+        transaction = self.client.session[f'google-oauth2_oauth2_state_{state}']
+        self.assertEqual(transaction['state'], state)
 
 
     @override_settings(AUTHENTICATION_BACKENDS=SSO_BACKENDS)
     @override_settings(AUTHENTICATION_BACKENDS=SSO_BACKENDS)
     def test_next_recorded_in_session(self):
     def test_next_recorded_in_session(self):
@@ -1273,7 +1275,7 @@ class SocialAuthExceptionMiddlewareTestCase(SimpleTestCase):
         The raw exception text should never be surfaced to the user.
         The raw exception text should never be surfaced to the user.
         """
         """
         request = self._make_request()
         request = self._make_request()
-        exception = AuthFailed(self.FakeBackend(), 'raw internal SAML detail')
+        exception = AuthResponseError(self.FakeBackend(), 'raw internal SAML detail')
         self.assertEqual(self.middleware.get_message(request, exception), self.GENERIC_MESSAGE)
         self.assertEqual(self.middleware.get_message(request, exception), self.GENERIC_MESSAGE)
 
 
     def test_redirect_on_failure(self):
     def test_redirect_on_failure(self):
@@ -1281,7 +1283,7 @@ class SocialAuthExceptionMiddlewareTestCase(SimpleTestCase):
         A SocialAuthBaseException should redirect to the login page with the generic message set.
         A SocialAuthBaseException should redirect to the login page with the generic message set.
         """
         """
         request = self._make_request()
         request = self._make_request()
-        exception = AuthFailed(self.FakeBackend(), 'raw internal SAML detail')
+        exception = AuthResponseError(self.FakeBackend(), 'raw internal SAML detail')
         response = self.middleware.process_exception(request, exception)
         response = self.middleware.process_exception(request, exception)
 
 
         self.assertEqual(response.status_code, 302)
         self.assertEqual(response.status_code, 302)

+ 2 - 2
requirements.txt

@@ -34,8 +34,8 @@ PyYAML==6.0.4
 redis==8.1.0
 redis==8.1.0
 requests==2.34.2
 requests==2.34.2
 rq==2.12.0
 rq==2.12.0
-social-auth-app-django==6.1.0
-social-auth-core==5.2.0
+social-auth-app-django==8.2.0
+social-auth-core==7.3.0
 sorl-thumbnail==13.5.0
 sorl-thumbnail==13.5.0
 strawberry-graphql==0.341.2
 strawberry-graphql==0.341.2
 strawberry-graphql-django==0.96.3
 strawberry-graphql-django==0.96.3