Merge pull request #21282 from edx/arch/depr-15-notes-token
DEPR-15: Remove usage of firebase-token-generator
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
"""
|
||||
This file contains a function used to retrieve the token for the annotation backend
|
||||
without having to create a view, but just returning a string instead.
|
||||
|
||||
It can be called from other files by using the following:
|
||||
from xmodule.annotator_token import retrieve_token
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
|
||||
from firebase_token_generator import create_token
|
||||
|
||||
|
||||
def retrieve_token(userid, secret):
|
||||
'''
|
||||
Return a token for the backend of annotations.
|
||||
It uses the course id to retrieve a variable that contains the secret
|
||||
token found in inheritance.py. It also contains information of when
|
||||
the token was issued. This will be stored with the user along with
|
||||
the id for identification purposes in the backend.
|
||||
'''
|
||||
|
||||
# the following five lines of code allows you to include the default timezone in the iso format
|
||||
# for more information: http://stackoverflow.com/questions/3401428/how-to-get-an-isoformat-datetime-string-including-the-default-timezone
|
||||
dtnow = datetime.datetime.now()
|
||||
dtutcnow = datetime.datetime.utcnow()
|
||||
delta = dtnow - dtutcnow
|
||||
newhour, newmin = divmod((delta.days * 24 * 60 * 60 + delta.seconds + 30) // 60, 60)
|
||||
newtime = "%s%+02d:%02d" % (dtnow.isoformat(), newhour, newmin)
|
||||
# uses the issued time (UTC plus timezone), the consumer key and the user's email to maintain a
|
||||
# federated system in the annotation backend server
|
||||
custom_data = {"issuedAt": newtime, "consumerKey": secret, "userId": userid, "ttl": 86400}
|
||||
newtoken = create_token(secret, custom_data)
|
||||
return newtoken
|
||||
@@ -1,26 +0,0 @@
|
||||
"""
|
||||
This test will run for annotator_token.py
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
|
||||
from xmodule.annotator_token import retrieve_token
|
||||
|
||||
|
||||
class TokenRetriever(unittest.TestCase):
|
||||
"""
|
||||
Tests to make sure that when passed in a username and secret token, that it will be encoded correctly
|
||||
"""
|
||||
|
||||
def test_token(self):
|
||||
"""
|
||||
Test for the token generator. Give an a random username and secret token,
|
||||
it should create the properly encoded string of text.
|
||||
"""
|
||||
expected = "eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJpc3N1ZWRBdCI6ICIyMDE0LTAyLTI3VDE3OjAwOjQyLjQwNjQ0MSswOjAwIiwgImNvbnN1bWVyS2V5IjogImZha2Vfc2VjcmV0IiwgInVzZXJJZCI6ICJ1c2VybmFtZSIsICJ0dGwiOiA4NjQwMH0.Dx1PoF-7mqBOOSGDMZ9R_s3oaaLRPnn6CJgGGF2A5CQ"
|
||||
response = retrieve_token("username", "fake_secret")
|
||||
|
||||
# because the middle hashes are dependent on time, conly the header and footer are checked for secret key
|
||||
self.assertEqual(expected.split('.')[0], response.split('.')[0])
|
||||
self.assertNotEqual(expected.split('.')[2], response.split('.')[2])
|
||||
@@ -15,7 +15,6 @@ from courseware.tabs import EnrolledTab
|
||||
from edxmako.shortcuts import render_to_response
|
||||
from notes.models import Note
|
||||
from notes.utils import notes_enabled_for_course
|
||||
from xmodule.annotator_token import retrieve_token
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -35,7 +34,7 @@ def notes(request, course_id):
|
||||
'notes': notes,
|
||||
'student': student,
|
||||
'storage': storage,
|
||||
'token': retrieve_token(student.email, course.annotation_token_secret),
|
||||
'token': None,
|
||||
'default_tab': 'myNotes',
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,6 @@ edxval
|
||||
enum34==1.1.6 # Backport of Enum from Python 3.4+
|
||||
event-tracking
|
||||
feedparser==5.1.3
|
||||
firebase-token-generator==1.3.2
|
||||
fs==2.0.18
|
||||
fs-s3fs==0.1.8
|
||||
glob2 # Enhanced glob module, used in openedx.core.lib.rooted_paths
|
||||
|
||||
@@ -126,7 +126,6 @@ elasticsearch==1.9.0 # via edx-search
|
||||
enum34==1.1.6
|
||||
event-tracking==0.2.9
|
||||
feedparser==5.1.3
|
||||
firebase-token-generator==1.3.2
|
||||
fs-s3fs==0.1.8
|
||||
fs==2.0.18
|
||||
future==0.17.1 # via edx-celeryutils, edx-enterprise, pyjwkest
|
||||
|
||||
@@ -154,7 +154,6 @@ faker==2.0.0
|
||||
faulthandler==3.1 ; python_version == "2.7"
|
||||
feedparser==5.1.3
|
||||
filelock==3.0.12
|
||||
firebase-token-generator==1.3.2
|
||||
flake8-polyfill==1.0.2
|
||||
flake8==3.7.8
|
||||
flask==1.1.1
|
||||
|
||||
@@ -149,7 +149,6 @@ faker==2.0.0 # via factory-boy
|
||||
faulthandler==3.1 ; python_version == "2.7" # via pytest-faulthandler
|
||||
feedparser==5.1.3
|
||||
filelock==3.0.12 # via tox
|
||||
firebase-token-generator==1.3.2
|
||||
flake8-polyfill==1.0.2 # via radon
|
||||
flake8==3.7.8 # via flake8-polyfill
|
||||
flask==1.1.1 # via moto
|
||||
|
||||
Reference in New Issue
Block a user