Upgraded to Python Social Auth 0.2.21 to resolve migration issue
This commit is contained in:
committed by
Clinton Blackburn
parent
5cd3a86382
commit
4cc7628696
@@ -10,10 +10,7 @@ settings.INSTALLED_APPS # pylint: disable=pointless-statement
|
||||
|
||||
from openedx.core.lib.django_startup import autostartup
|
||||
import django
|
||||
from openedx.core.djangoapps.monkey_patch import (
|
||||
third_party_auth,
|
||||
django_db_models_options
|
||||
)
|
||||
from openedx.core.djangoapps.monkey_patch import django_db_models_options
|
||||
from openedx.core.lib.xblock_utils import xblock_local_resource_url
|
||||
|
||||
import xmodule.x_module
|
||||
@@ -28,7 +25,6 @@ def run():
|
||||
"""
|
||||
Executed during django startup
|
||||
"""
|
||||
third_party_auth.patch()
|
||||
django_db_models_options.patch()
|
||||
|
||||
# Comprehensive theming needs to be set up before django startup,
|
||||
|
||||
@@ -44,11 +44,6 @@ class SAMLAuthBackend(SAMLAuth): # pylint: disable=abstract-method
|
||||
log.error('SAML authentication is not enabled')
|
||||
raise Http404
|
||||
|
||||
# TODO: remove this check once the fix is merged upstream:
|
||||
# https://github.com/omab/python-social-auth/pull/821
|
||||
if 'idp' not in self.strategy.request_data():
|
||||
raise AuthMissingParameter(self, 'idp')
|
||||
|
||||
return super(SAMLAuthBackend, self).auth_url()
|
||||
|
||||
def _check_entitlements(self, idp, attributes):
|
||||
|
||||
@@ -413,8 +413,10 @@ class IntegrationTest(testutil.TestCase, test.TestCase):
|
||||
def assert_redirect_to_dashboard_looks_correct(self, response):
|
||||
"""Asserts a response would redirect to /dashboard."""
|
||||
self.assertEqual(302, response.status_code)
|
||||
# NOTE: Ideally we should use assertRedirects(), however it errors out due to the hostname, testserver,
|
||||
# not being properly set. This may be an issue with the call made by PSA, but we are not certain.
|
||||
# pylint: disable=protected-access
|
||||
self.assertEqual(auth_settings._SOCIAL_AUTH_LOGIN_REDIRECT_URL, response.get('Location'))
|
||||
self.assertTrue(response.get('Location').endswith(django_settings.SOCIAL_AUTH_LOGIN_REDIRECT_URL))
|
||||
|
||||
def assert_redirect_to_login_looks_correct(self, response):
|
||||
"""Asserts a response would redirect to /login."""
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
import json
|
||||
|
||||
import httpretty
|
||||
|
||||
from provider.constants import PUBLIC
|
||||
from provider.oauth2.models import Client
|
||||
from social.apps.django_app.default.models import UserSocialAuth
|
||||
|
||||
from social.backends.facebook import FacebookOAuth2
|
||||
from student.tests.factories import UserFactory
|
||||
|
||||
from .testutil import ThirdPartyAuthTestMixin
|
||||
@@ -81,7 +80,7 @@ class ThirdPartyOAuthTestMixin(ThirdPartyAuthTestMixin):
|
||||
class ThirdPartyOAuthTestMixinFacebook(object):
|
||||
"""Tests oauth with the Facebook backend"""
|
||||
BACKEND = "facebook"
|
||||
USER_URL = "https://graph.facebook.com/v2.3/me"
|
||||
USER_URL = FacebookOAuth2.USER_DATA_URL
|
||||
# In facebook responses, the "id" field is used as the user's identifier
|
||||
UID_FIELD = "id"
|
||||
|
||||
|
||||
@@ -2175,11 +2175,6 @@ INSTALLED_APPS = (
|
||||
'database_fixups',
|
||||
)
|
||||
|
||||
# Migrations which are not in the standard module "migrations"
|
||||
MIGRATION_MODULES = {
|
||||
'social.apps.django_app.default': 'social.apps.django_app.default.south_migrations'
|
||||
}
|
||||
|
||||
######################### CSRF #########################################
|
||||
|
||||
# Forwards-compatibility with Django 1.7
|
||||
|
||||
@@ -12,10 +12,7 @@ settings.INSTALLED_APPS # pylint: disable=pointless-statement
|
||||
from openedx.core.lib.django_startup import autostartup
|
||||
import logging
|
||||
import analytics
|
||||
from openedx.core.djangoapps.monkey_patch import (
|
||||
third_party_auth,
|
||||
django_db_models_options
|
||||
)
|
||||
from openedx.core.djangoapps.monkey_patch import django_db_models_options
|
||||
|
||||
import xmodule.x_module
|
||||
import lms_xblock.runtime
|
||||
@@ -33,7 +30,6 @@ def run():
|
||||
"""
|
||||
Executed during django startup
|
||||
"""
|
||||
third_party_auth.patch()
|
||||
django_db_models_options.patch()
|
||||
|
||||
# To override the settings before executing the autostartup() for python-social-auth
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
"""
|
||||
Monkey patch implementation for a python_social_auth Django ORM method that is not Django 1.8-compatible.
|
||||
Remove once the module fully supports Django 1.8!
|
||||
"""
|
||||
|
||||
from django.db import transaction
|
||||
from social.storage.django_orm import DjangoUserMixin
|
||||
from social.apps.django_app.default.models import (
|
||||
UserSocialAuth, Nonce, Association, Code
|
||||
)
|
||||
|
||||
|
||||
def patch():
|
||||
"""
|
||||
Monkey-patch the DjangoUserMixin class.
|
||||
"""
|
||||
def create_social_auth_wrapper(wrapped_func):
|
||||
# pylint: disable=missing-docstring
|
||||
wrapped_func = wrapped_func.__func__
|
||||
|
||||
def _create_social_auth(*args, **kwargs):
|
||||
# The entire reason for this monkey-patch is to wrap the create_social_auth call
|
||||
# in an atomic transaction. The call can sometime raise an IntegrityError, which is
|
||||
# caught and dealt with by python_social_auth - but not inside of an atomic transaction.
|
||||
# In Django 1.8, unless the exception is raised in an atomic transaction, the transaction
|
||||
# becomes unusable after the IntegrityError exception is raised.
|
||||
with transaction.atomic():
|
||||
return wrapped_func(*args, **kwargs)
|
||||
return classmethod(_create_social_auth)
|
||||
|
||||
DjangoUserMixin.create_social_auth = create_social_auth_wrapper(DjangoUserMixin.create_social_auth)
|
||||
|
||||
# Monkey-patch some social auth models' Meta class to squelch Django19 warnings.
|
||||
# pylint: disable=protected-access
|
||||
UserSocialAuth._meta.app_label = "default"
|
||||
Nonce._meta.app_label = "default"
|
||||
Association._meta.app_label = "default"
|
||||
Code._meta.app_label = "default"
|
||||
@@ -90,12 +90,7 @@ python-memcached==1.48
|
||||
django-memcached-hashring==0.1.2
|
||||
python-openid==2.2.5
|
||||
python-dateutil==2.1
|
||||
|
||||
# This module gets monkey-patched in third_party_auth.py to fix a Django 1.8 incompatibility.
|
||||
# When this dependency gets upgraded, the monkey patch should be removed, if possible.
|
||||
# We can also remove the fix to auth_url in third_party_auth/saml.py when that fix is included upstream.
|
||||
python-social-auth==0.2.12
|
||||
|
||||
python-social-auth==0.2.21
|
||||
pytz==2016.7
|
||||
pysrt==0.4.7
|
||||
PyYAML==3.10
|
||||
|
||||
Reference in New Issue
Block a user