Remove deprecated JwtBuilder

ARCH-248
This commit is contained in:
Nimisha Asthagiri
2018-10-14 00:32:18 -04:00
parent f5a643f53b
commit dc56a63e03
16 changed files with 38 additions and 142 deletions

View File

@@ -24,7 +24,7 @@ from courseware.courses import get_current_child
from edxnotes.exceptions import EdxNotesParseError, EdxNotesServiceUnavailable
from edxnotes.plugins import EdxNotesTab
from lms.lib.utils import get_parent_unit
from openedx.core.lib.token_utils import JwtBuilder
from openedx.core.djangoapps.oauth_dispatch.jwt import create_jwt_for_user
from student.models import anonymous_id_for_user
from util.date_utils import get_default_time_display
from xmodule.modulestore.django import modulestore
@@ -59,12 +59,7 @@ def get_edxnotes_id_token(user):
raise ImproperlyConfigured(
'OAuth2 Client with name [{}] does not exist.'.format(CLIENT_NAME)
)
scopes = ['email', 'profile']
expires_in = settings.OAUTH_ID_TOKEN_EXPIRATION
jwt = JwtBuilder(user, secret=client.client_secret).build_token(scopes, expires_in, aud=client.client_id)
return jwt
return create_jwt_for_user(user, secret=client.client_secret, aud=client.client_id)
def get_token_url(course_id):

View File

@@ -27,9 +27,9 @@ from edxnotes import helpers
from edxnotes.decorators import edxnotes
from edxnotes.exceptions import EdxNotesParseError, EdxNotesServiceUnavailable
from edxnotes.plugins import EdxNotesTab
from openedx.core.djangoapps.oauth_dispatch.jwt import create_jwt_for_user
from openedx.core.djangoapps.user_api.models import RetirementState, UserRetirementStatus
from openedx.core.lib.tests import attr
from openedx.core.lib.token_utils import JwtBuilder
from student.tests.factories import CourseEnrollmentFactory, SuperuserFactory, UserFactory
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
@@ -1185,7 +1185,7 @@ class EdxNotesRetireAPITest(ModuleStoreTestCase):
"""
Helper function for creating headers for the JWT authentication.
"""
token = JwtBuilder(user).build_token([])
token = create_jwt_for_user(user)
headers = {'HTTP_AUTHORIZATION': 'JWT ' + token}
return headers