From 55bea73035690122afc2a8e24989f6ca042ee393 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 19 Apr 2017 10:05:04 -0700 Subject: [PATCH] Revert "github: Call the appropriate authenticate." This reverts commit ab260731a98b8edd4884826cedbb042981e1dfff. The overridden authenticate method was buggy. --- zerver/tests/test_auth_backends.py | 7 ++++--- zproject/backends.py | 8 +------- zproject/settings.py | 1 - 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py index b23322d762..a4fa79520d 100644 --- a/zerver/tests/test_auth_backends.py +++ b/zerver/tests/test_auth_backends.py @@ -39,12 +39,13 @@ from zproject.backends import ZulipDummyBackend, EmailAuthBackend, \ GoogleMobileOauth2Backend, ZulipRemoteUserBackend, ZulipLDAPAuthBackend, \ ZulipLDAPUserPopulator, DevAuthBackend, GitHubAuthBackend, ZulipAuthMixin, \ dev_auth_enabled, password_auth_enabled, github_auth_enabled, \ - SocialAuthMixin, AUTH_BACKEND_NAME_MAP, SocialAuthStrategy + SocialAuthMixin, AUTH_BACKEND_NAME_MAP from zerver.views.auth import maybe_send_to_registration from version import ZULIP_VERSION from social_core.exceptions import AuthFailed, AuthStateForbidden +from social_django.strategy import DjangoStrategy from social_django.storage import BaseDjangoStorage from social_core.backends.github import GithubOrganizationOAuth2, GithubTeamOAuth2, \ GithubOAuth2 @@ -391,7 +392,7 @@ class GitHubAuthBackendTest(ZulipTestCase): self.email = 'hamlet@zulip.com' self.name = 'Hamlet' self.backend = GitHubAuthBackend() - self.backend.strategy = SocialAuthStrategy(storage=BaseDjangoStorage()) + self.backend.strategy = DjangoStrategy(storage=BaseDjangoStorage()) self.user_profile = get_user_profile_by_email(self.email) self.user_profile.backend = self.backend @@ -405,7 +406,7 @@ class GitHubAuthBackendTest(ZulipTestCase): def do_auth(self, *args, **kwargs): # type: (*Any, **Any) -> UserProfile with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.GitHubAuthBackend',)): - return self.backend.strategy.authenticate(self.backend, **kwargs) + return self.backend.authenticate(**kwargs) def test_github_auth_enabled(self): # type: () -> None diff --git a/zproject/backends.py b/zproject/backends.py index c442e9e999..59576be16f 100644 --- a/zproject/backends.py +++ b/zproject/backends.py @@ -17,7 +17,6 @@ from zerver.models import UserProfile, Realm, get_user_profile_by_id, \ from apiclient.sample_tools import client as googleapiclient from oauth2client.crypt import AppIdentityError -from social_core.backends.base import BaseAuth from social_core.backends.github import GithubOAuth2, GithubOrganizationOAuth2, \ GithubTeamOAuth2 from social_core.exceptions import AuthFailed, SocialAuthBaseException @@ -103,11 +102,6 @@ class ZulipAuthMixin(object): except UserProfile.DoesNotExist: return None -class SocialAuthStrategy(DjangoStrategy): - def authenticate(self, backend, *args, **kwargs): - # type: (BaseAuth, *Any, **Any) -> None - return backend.authenticate(*args, **kwargs) - class SocialAuthMixin(ZulipAuthMixin): auth_backend_name = None # type: Text @@ -122,7 +116,7 @@ class SocialAuthMixin(ZulipAuthMixin): def authenticate(self, realm_subdomain='', # type: Optional[Text] storage=None, # type: Optional[DjangoStorage] - strategy=None, # type: Optional[SocialAuthStrategy] + strategy=None, # type: Optional[DjangoStrategy] user=None, # type: Optional[Dict[str, Any]] return_data=None, # type: Optional[Dict[str, Any]] response=None, # type: Optional[Dict[str, Any]] diff --git a/zproject/settings.py b/zproject/settings.py index a60e6d23e0..2cbf1d401e 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -1209,7 +1209,6 @@ SOCIAL_AUTH_GITHUB_ORG_KEY = SOCIAL_AUTH_GITHUB_KEY SOCIAL_AUTH_GITHUB_ORG_SECRET = SOCIAL_AUTH_GITHUB_SECRET SOCIAL_AUTH_GITHUB_TEAM_KEY = SOCIAL_AUTH_GITHUB_KEY SOCIAL_AUTH_GITHUB_TEAM_SECRET = SOCIAL_AUTH_GITHUB_SECRET -SOCIAL_AUTH_STRATEGY = 'zproject.backends.SocialAuthStrategy' ######################################################################## # EMAIL SETTINGS