Commit 8d4db4ac by Clinton Blackburn

Updated Course Structure API views to use JWT authentication

LEARNER-1375
parent 0b07b53e
...@@ -4,14 +4,15 @@ import logging ...@@ -4,14 +4,15 @@ import logging
from django.conf import settings from django.conf import settings
from django.http import Http404 from django.http import Http404
from edx_rest_framework_extensions.authentication import JwtAuthentication
from opaque_keys.edx.keys import CourseKey
from rest_framework.authentication import SessionAuthentication from rest_framework.authentication import SessionAuthentication
from rest_framework_oauth.authentication import OAuth2Authentication
from rest_framework.exceptions import AuthenticationFailed from rest_framework.exceptions import AuthenticationFailed
from rest_framework.generics import RetrieveAPIView, ListAPIView from rest_framework.generics import RetrieveAPIView, ListAPIView
from rest_framework.permissions import IsAuthenticated from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework_oauth.authentication import OAuth2Authentication
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from opaque_keys.edx.keys import CourseKey
from course_structure_api.v0 import serializers from course_structure_api.v0 import serializers
from courseware import courses from courseware import courses
...@@ -20,7 +21,6 @@ from openedx.core.djangoapps.content.course_structures.api.v0 import api, errors ...@@ -20,7 +21,6 @@ from openedx.core.djangoapps.content.course_structures.api.v0 import api, errors
from openedx.core.lib.exceptions import CourseNotFoundError from openedx.core.lib.exceptions import CourseNotFoundError
from student.roles import CourseInstructorRole, CourseStaffRole from student.roles import CourseInstructorRole, CourseStaffRole
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -29,7 +29,7 @@ class CourseViewMixin(object): ...@@ -29,7 +29,7 @@ class CourseViewMixin(object):
Mixin for views dealing with course content. Also handles authorization and authentication. Mixin for views dealing with course content. Also handles authorization and authentication.
""" """
lookup_field = 'course_id' lookup_field = 'course_id'
authentication_classes = (OAuth2Authentication, SessionAuthentication,) authentication_classes = (JwtAuthentication, OAuth2Authentication, SessionAuthentication,)
permission_classes = (IsAuthenticated,) permission_classes = (IsAuthenticated,)
def get_course_or_404(self): def get_course_or_404(self):
...@@ -55,6 +55,7 @@ class CourseViewMixin(object): ...@@ -55,6 +55,7 @@ class CourseViewMixin(object):
:param func: function to be wrapped :param func: function to be wrapped
:returns: the wrapped function :returns: the wrapped function
""" """
def func_wrapper(self, *args, **kwargs): def func_wrapper(self, *args, **kwargs):
"""Wrapper function for this decorator. """Wrapper function for this decorator.
......
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