From c1a5d2fa06afcd4bc9b4177a719965c968dc276f Mon Sep 17 00:00:00 2001 From: Nimisha Asthagiri Date: Thu, 1 Aug 2019 18:51:02 -0400 Subject: [PATCH] DEPR-15: Remove usage of firebase-token-generator The old Notes Django app is the only caller of this no longer supported library. I have verified that this old app is no longer functional and is already slated to be removed as part of DEPR-18. So this commit simply removes the call to firebase-token-generator and leaves removal of the Notes app to DEPR-18. --- common/lib/xmodule/xmodule/annotator_token.py | 35 ------------------- .../xmodule/tests/test_annotator_token.py | 26 -------------- lms/djangoapps/notes/views.py | 3 +- requirements/edx/base.in | 1 - requirements/edx/base.txt | 1 - requirements/edx/development.txt | 1 - requirements/edx/testing.txt | 1 - 7 files changed, 1 insertion(+), 67 deletions(-) delete mode 100644 common/lib/xmodule/xmodule/annotator_token.py delete mode 100644 common/lib/xmodule/xmodule/tests/test_annotator_token.py diff --git a/common/lib/xmodule/xmodule/annotator_token.py b/common/lib/xmodule/xmodule/annotator_token.py deleted file mode 100644 index 282f13e367..0000000000 --- a/common/lib/xmodule/xmodule/annotator_token.py +++ /dev/null @@ -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 diff --git a/common/lib/xmodule/xmodule/tests/test_annotator_token.py b/common/lib/xmodule/xmodule/tests/test_annotator_token.py deleted file mode 100644 index 86b2258f59..0000000000 --- a/common/lib/xmodule/xmodule/tests/test_annotator_token.py +++ /dev/null @@ -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]) diff --git a/lms/djangoapps/notes/views.py b/lms/djangoapps/notes/views.py index 14d5d0033b..6489689b63 100644 --- a/lms/djangoapps/notes/views.py +++ b/lms/djangoapps/notes/views.py @@ -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', } diff --git a/requirements/edx/base.in b/requirements/edx/base.in index 3796bb23ba..8cdd7c7d82 100644 --- a/requirements/edx/base.in +++ b/requirements/edx/base.in @@ -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 diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index cd87346549..88de087f01 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -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 diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index 1e74b96726..e42823d6ec 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -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 diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index b0cbac5946..2fbfff9ceb 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -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