Commit 03c3ee53 by Andy Armstrong

Move cors_crsf to openedx/core

parent 8c22d522
......@@ -252,6 +252,7 @@ MAKO_TEMPLATES['main'] = [
COMMON_ROOT / 'templates',
COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates',
COMMON_ROOT / 'static', # required to statically include common Underscore templates
OPENEDX_ROOT / 'core' / 'djangoapps' / 'cors_csrf' / 'templates',
OPENEDX_ROOT / 'core' / 'djangoapps' / 'dark_lang' / 'templates',
CMS_ROOT / 'djangoapps' / 'pipeline_js' / 'templates',
]
......
......@@ -18,8 +18,8 @@ from rest_framework.throttling import UserRateThrottle
from rest_framework.views import APIView
from opaque_keys.edx.keys import CourseKey
from embargo import api as embargo_api
from cors_csrf.authentication import SessionAuthenticationCrossDomainCsrf
from cors_csrf.decorators import ensure_csrf_cookie_cross_domain
from openedx.core.djangoapps.cors_csrf.authentication import SessionAuthenticationCrossDomainCsrf
from openedx.core.djangoapps.cors_csrf.decorators import ensure_csrf_cookie_cross_domain
from openedx.core.lib.api.authentication import (
SessionAuthenticationAllowInactiveUser,
OAuth2AuthenticationAllowInactiveUser,
......
......@@ -471,6 +471,7 @@ MAKO_TEMPLATES['main'] = [
COMMON_ROOT / 'templates',
COMMON_ROOT / 'lib' / 'capa' / 'capa' / 'templates',
COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates',
OPENEDX_ROOT / 'core' / 'djangoapps' / 'cors_csrf' / 'templates',
OPENEDX_ROOT / 'core' / 'djangoapps' / 'dark_lang' / 'templates',
]
......@@ -1129,8 +1130,8 @@ MIDDLEWARE_CLASSES = (
# CORS and CSRF
'corsheaders.middleware.CorsMiddleware',
'cors_csrf.middleware.CorsCSRFMiddleware',
'cors_csrf.middleware.CsrfCrossDomainCookieMiddleware',
'openedx.core.djangoapps.cors_csrf.middleware.CorsCSRFMiddleware',
'openedx.core.djangoapps.cors_csrf.middleware.CsrfCrossDomainCookieMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'splash.middleware.SplashMiddleware',
......@@ -2072,7 +2073,7 @@ INSTALLED_APPS = (
# CORS and cross-domain CSRF
'corsheaders',
'cors_csrf',
'openedx.core.djangoapps.cors_csrf',
'commerce',
......
......@@ -884,7 +884,7 @@ urlpatterns += (
# XDomain proxy
urlpatterns += (
url(r'^xdomain_proxy.html$', 'cors_csrf.views.xdomain_proxy', name='xdomain_proxy'),
url(r'^xdomain_proxy.html$', 'openedx.core.djangoapps.cors_csrf.views.xdomain_proxy', name='xdomain_proxy'),
)
# Custom courses on edX (CCX) URLs
......
"""Manage cross-domain configuration. """
"""
Manage cross-domain configuration.
"""
from django.contrib import admin
from config_models.admin import ConfigurationModelAdmin
from cors_csrf.models import XDomainProxyConfiguration
from .models import XDomainProxyConfiguration
admin.site.register(XDomainProxyConfiguration, ConfigurationModelAdmin)
"""Django Rest Framework Authentication classes for cross-domain end-points."""
"""
Django Rest Framework Authentication classes for cross-domain end-points.
"""
from rest_framework import authentication
from cors_csrf.helpers import is_cross_domain_request_allowed, skip_cross_domain_referer_check
from .helpers import is_cross_domain_request_allowed, skip_cross_domain_referer_check
class SessionAuthenticationCrossDomainCsrf(authentication.SessionAuthentication):
......
......@@ -48,7 +48,7 @@ from django.conf import settings
from django.middleware.csrf import CsrfViewMiddleware
from django.core.exceptions import MiddlewareNotUsed, ImproperlyConfigured
from cors_csrf.helpers import is_cross_domain_request_allowed, skip_cross_domain_referer_check
from .helpers import is_cross_domain_request_allowed, skip_cross_domain_referer_check
log = logging.getLogger(__name__)
......
......@@ -7,7 +7,7 @@ from config_models.models import ConfigurationModel
class XDomainProxyConfiguration(ConfigurationModel):
"""Cross-domain proxy configuration.
See `cors_csrf.views.xdomain_proxy` for an explanation of how this works.
See `openedx.core.djangoapps.cors_csrf.views.xdomain_proxy` for an explanation of how this works.
"""
......@@ -17,3 +17,6 @@ class XDomainProxyConfiguration(ConfigurationModel):
u"requests to this site. Please list each domain on its own line."
)
)
def __unicode__(self):
return "XDomainProxyConfiguration()"
......@@ -8,7 +8,7 @@ from django.conf import settings
from rest_framework.exceptions import PermissionDenied
from cors_csrf.authentication import SessionAuthenticationCrossDomainCsrf
from ..authentication import SessionAuthenticationCrossDomainCsrf
class CrossDomainAuthTest(TestCase):
......
......@@ -3,7 +3,8 @@ import json
import mock
from django.http import HttpResponse
from django.test import TestCase
from cors_csrf.decorators import ensure_csrf_cookie_cross_domain
from ..decorators import ensure_csrf_cookie_cross_domain
def fake_view(request):
......
......@@ -11,7 +11,7 @@ from django.core.exceptions import MiddlewareNotUsed, ImproperlyConfigured
from django.http import HttpResponse
from django.middleware.csrf import CsrfViewMiddleware
from cors_csrf.middleware import CorsCSRFMiddleware, CsrfCrossDomainCookieMiddleware
from ..middleware import CorsCSRFMiddleware, CsrfCrossDomainCookieMiddleware
SENTINEL = object()
......
"""Tests for cross-domain request views. """
import ddt
import json
from django.test import TestCase
from django.core.urlresolvers import reverse, NoReverseMatch
import ddt
from config_models.models import cache
from cors_csrf.models import XDomainProxyConfiguration
from ..models import XDomainProxyConfiguration
@ddt.ddt
......
......@@ -5,7 +5,8 @@ from django.conf import settings
from django.views.decorators.cache import cache_page
from django.http import HttpResponseNotFound
from edxmako.shortcuts import render_to_response
from cors_csrf.models import XDomainProxyConfiguration
from .models import XDomainProxyConfiguration
log = logging.getLogger(__name__)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment