diff --git a/openedx/core/djangoapps/cors_csrf/admin.py b/openedx/core/djangoapps/cors_csrf/admin.py index 34449cd9b4..a27c99ff6e 100644 --- a/openedx/core/djangoapps/cors_csrf/admin.py +++ b/openedx/core/djangoapps/cors_csrf/admin.py @@ -2,6 +2,8 @@ Manage cross-domain configuration. """ +from __future__ import absolute_import + from config_models.admin import ConfigurationModelAdmin from django.contrib import admin diff --git a/openedx/core/djangoapps/cors_csrf/authentication.py b/openedx/core/djangoapps/cors_csrf/authentication.py index 7640c248be..fc7b1e48cc 100644 --- a/openedx/core/djangoapps/cors_csrf/authentication.py +++ b/openedx/core/djangoapps/cors_csrf/authentication.py @@ -1,6 +1,8 @@ """ Django Rest Framework Authentication classes for cross-domain end-points. """ +from __future__ import absolute_import + from django.middleware.csrf import CsrfViewMiddleware from rest_framework import authentication diff --git a/openedx/core/djangoapps/cors_csrf/decorators.py b/openedx/core/djangoapps/cors_csrf/decorators.py index db3913ceb7..5da86e4927 100644 --- a/openedx/core/djangoapps/cors_csrf/decorators.py +++ b/openedx/core/djangoapps/cors_csrf/decorators.py @@ -1,4 +1,6 @@ """Decorators for cross-domain CSRF. """ +from __future__ import absolute_import + from django.views.decorators.csrf import ensure_csrf_cookie diff --git a/openedx/core/djangoapps/cors_csrf/helpers.py b/openedx/core/djangoapps/cors_csrf/helpers.py index 6131de5074..423854c22e 100644 --- a/openedx/core/djangoapps/cors_csrf/helpers.py +++ b/openedx/core/djangoapps/cors_csrf/helpers.py @@ -1,7 +1,9 @@ """Helper methods for CORS and CSRF checks. """ +from __future__ import absolute_import + import contextlib import logging -import urlparse +import six.moves.urllib.parse # pylint: disable=import-error from django.conf import settings @@ -24,7 +26,7 @@ def is_cross_domain_request_allowed(request): """ referer = request.META.get('HTTP_REFERER') - referer_parts = urlparse.urlparse(referer) if referer else None + referer_parts = six.moves.urllib.parse.urlparse(referer) if referer else None referer_hostname = referer_parts.hostname if referer_parts is not None else None # Use CORS_ALLOW_INSECURE *only* for development and testing environments; diff --git a/openedx/core/djangoapps/cors_csrf/middleware.py b/openedx/core/djangoapps/cors_csrf/middleware.py index 805354e26d..5d860531e1 100644 --- a/openedx/core/djangoapps/cors_csrf/middleware.py +++ b/openedx/core/djangoapps/cors_csrf/middleware.py @@ -42,6 +42,8 @@ CSRF cookie. """ +from __future__ import absolute_import + import logging from django.conf import settings diff --git a/openedx/core/djangoapps/cors_csrf/migrations/0001_initial.py b/openedx/core/djangoapps/cors_csrf/migrations/0001_initial.py index f29fbb1d7e..254e6afaef 100644 --- a/openedx/core/djangoapps/cors_csrf/migrations/0001_initial.py +++ b/openedx/core/djangoapps/cors_csrf/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/openedx/core/djangoapps/cors_csrf/models.py b/openedx/core/djangoapps/cors_csrf/models.py index 1cc1410245..d0ec0d1b1b 100644 --- a/openedx/core/djangoapps/cors_csrf/models.py +++ b/openedx/core/djangoapps/cors_csrf/models.py @@ -1,4 +1,6 @@ """Models for cross-domain configuration. """ +from __future__ import absolute_import + from config_models.models import ConfigurationModel from django.db import models from django.utils.translation import ugettext_lazy as _ diff --git a/openedx/core/djangoapps/cors_csrf/tests/test_authentication.py b/openedx/core/djangoapps/cors_csrf/tests/test_authentication.py index 4adbe2aa5a..ae62df2a0f 100644 --- a/openedx/core/djangoapps/cors_csrf/tests/test_authentication.py +++ b/openedx/core/djangoapps/cors_csrf/tests/test_authentication.py @@ -1,4 +1,6 @@ """Tests for the CORS CSRF version of Django Rest Framework's SessionAuthentication.""" +from __future__ import absolute_import + from mock import patch from django.middleware.csrf import get_token diff --git a/openedx/core/djangoapps/cors_csrf/tests/test_decorators.py b/openedx/core/djangoapps/cors_csrf/tests/test_decorators.py index 1fa1daf6f0..e41e772952 100644 --- a/openedx/core/djangoapps/cors_csrf/tests/test_decorators.py +++ b/openedx/core/djangoapps/cors_csrf/tests/test_decorators.py @@ -1,4 +1,6 @@ """Tests for cross-domain CSRF decorators. """ +from __future__ import absolute_import + import json import mock from django.http import HttpResponse diff --git a/openedx/core/djangoapps/cors_csrf/tests/test_middleware.py b/openedx/core/djangoapps/cors_csrf/tests/test_middleware.py index 294cd45b98..43ddfd6c17 100644 --- a/openedx/core/djangoapps/cors_csrf/tests/test_middleware.py +++ b/openedx/core/djangoapps/cors_csrf/tests/test_middleware.py @@ -2,6 +2,8 @@ Tests for the CORS CSRF middleware """ +from __future__ import absolute_import + from mock import patch, Mock import ddt diff --git a/openedx/core/djangoapps/cors_csrf/tests/test_views.py b/openedx/core/djangoapps/cors_csrf/tests/test_views.py index 278991fd2a..9710e9e747 100644 --- a/openedx/core/djangoapps/cors_csrf/tests/test_views.py +++ b/openedx/core/djangoapps/cors_csrf/tests/test_views.py @@ -1,5 +1,7 @@ """Tests for cross-domain request views. """ +from __future__ import absolute_import + import json import unittest diff --git a/openedx/core/djangoapps/cors_csrf/views.py b/openedx/core/djangoapps/cors_csrf/views.py index e3fa8fcee1..c9daaecd17 100644 --- a/openedx/core/djangoapps/cors_csrf/views.py +++ b/openedx/core/djangoapps/cors_csrf/views.py @@ -1,4 +1,6 @@ """Views for enabling cross-domain requests. """ +from __future__ import absolute_import + import json import logging