chore: Removed unused dependency
This commit is contained in:
11
.github/workflows/check_python_dependencies.yml
vendored
11
.github/workflows/check_python_dependencies.yml
vendored
@@ -14,18 +14,18 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
- name: Install repo-tools
|
- name: Install repo-tools
|
||||||
run: pip install edx-repo-tools[find_dependencies]
|
run: pip install edx-repo-tools[find_dependencies]
|
||||||
|
|
||||||
- name: Install setuptool
|
- name: Install setuptool
|
||||||
run: pip install setuptools
|
run: pip install setuptools
|
||||||
|
|
||||||
- name: Run Python script
|
- name: Run Python script
|
||||||
run: |
|
run: |
|
||||||
find_python_dependencies \
|
find_python_dependencies \
|
||||||
@@ -35,6 +35,5 @@ jobs:
|
|||||||
--ignore https://github.com/edx/braze-client \
|
--ignore https://github.com/edx/braze-client \
|
||||||
--ignore https://github.com/edx/edx-name-affirmation \
|
--ignore https://github.com/edx/edx-name-affirmation \
|
||||||
--ignore https://github.com/mitodl/edx-sga \
|
--ignore https://github.com/mitodl/edx-sga \
|
||||||
--ignore https://github.com/edx/token-utils \
|
|
||||||
--ignore https://github.com/open-craft/xblock-poll
|
--ignore https://github.com/open-craft/xblock-poll
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ from jwkest.jws import JWS
|
|||||||
|
|
||||||
from lms.djangoapps.courseware.jwt import _encode_and_sign, create_jwt, unpack_jwt
|
from lms.djangoapps.courseware.jwt import _encode_and_sign, create_jwt, unpack_jwt
|
||||||
|
|
||||||
import unittest
|
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
|
|
||||||
test_user_id = 121
|
test_user_id = 121
|
||||||
invalid_test_user_id = 120
|
invalid_test_user_id = 120
|
||||||
@@ -28,6 +25,10 @@ expected_full_token = {
|
|||||||
|
|
||||||
|
|
||||||
class TestSign(unittest.TestCase):
|
class TestSign(unittest.TestCase):
|
||||||
|
"""
|
||||||
|
Tests for JWT creation and signing.
|
||||||
|
"""
|
||||||
|
|
||||||
def test_create_jwt(self):
|
def test_create_jwt(self):
|
||||||
token = create_jwt(test_user_id, test_timeout, {}, test_now)
|
token = create_jwt(test_user_id, test_timeout, {}, test_now)
|
||||||
|
|
||||||
@@ -53,6 +54,7 @@ class TestSign(unittest.TestCase):
|
|||||||
with self.assertRaises(BadSignature):
|
with self.assertRaises(BadSignature):
|
||||||
_verify_jwt(token)
|
_verify_jwt(token)
|
||||||
|
|
||||||
|
|
||||||
def _verify_jwt(jwt_token):
|
def _verify_jwt(jwt_token):
|
||||||
"""
|
"""
|
||||||
Helper function which verifies the signature and decodes the token
|
Helper function which verifies the signature and decodes the token
|
||||||
@@ -65,6 +67,10 @@ def _verify_jwt(jwt_token):
|
|||||||
|
|
||||||
|
|
||||||
class TestUnpack(unittest.TestCase):
|
class TestUnpack(unittest.TestCase):
|
||||||
|
"""
|
||||||
|
Tests for JWT unpacking.
|
||||||
|
"""
|
||||||
|
|
||||||
def test_unpack_jwt(self):
|
def test_unpack_jwt(self):
|
||||||
token = create_jwt(test_user_id, test_timeout, {}, test_now)
|
token = create_jwt(test_user_id, test_timeout, {}, test_now)
|
||||||
decoded = unpack_jwt(token, test_user_id, test_now)
|
decoded = unpack_jwt(token, test_user_id, test_now)
|
||||||
|
|||||||
@@ -234,36 +234,3 @@ def _use_new_financial_assistance_flow(course_id):
|
|||||||
):
|
):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def unpack_jwt(token, lms_user_id, now=None):
|
|
||||||
"""
|
|
||||||
Unpack and verify an encoded JWT.
|
|
||||||
|
|
||||||
Validate the user and expiration.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
token (string): The token to be unpacked and verified.
|
|
||||||
lms_user_id (int): LMS user ID this token should match with.
|
|
||||||
now (int): Optional now value for testing.
|
|
||||||
|
|
||||||
Returns a valid, decoded json payload (string).
|
|
||||||
"""
|
|
||||||
now = now or int(time())
|
|
||||||
|
|
||||||
# Unpack and verify token
|
|
||||||
keys = jwk.KEYS()
|
|
||||||
keys.load_jwks(settings.TOKEN_SIGNING['JWT_PUBLIC_SIGNING_JWK_SET'])
|
|
||||||
payload = JWS().verify_compact(token.encode('utf-8'), keys)
|
|
||||||
|
|
||||||
if "lms_user_id" not in payload:
|
|
||||||
raise MissingKey("LMS user id is missing")
|
|
||||||
if "exp" not in payload:
|
|
||||||
raise MissingKey("Expiration is missing")
|
|
||||||
if payload["lms_user_id"] != lms_user_id:
|
|
||||||
raise Invalid("User does not match")
|
|
||||||
if payload["exp"] < now:
|
|
||||||
raise Expired("Token is expired")
|
|
||||||
|
|
||||||
return payload
|
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ from lms.djangoapps.courseware.courses import (
|
|||||||
)
|
)
|
||||||
from lms.djangoapps.courseware.date_summary import verified_upgrade_deadline_link
|
from lms.djangoapps.courseware.date_summary import verified_upgrade_deadline_link
|
||||||
from lms.djangoapps.courseware.exceptions import CourseAccessRedirect, Redirect
|
from lms.djangoapps.courseware.exceptions import CourseAccessRedirect, Redirect
|
||||||
|
from lms.djangoapps.courseware.jwt import unpack_jwt
|
||||||
from lms.djangoapps.courseware.masquerade import is_masquerading_as_specific_student, setup_masquerade
|
from lms.djangoapps.courseware.masquerade import is_masquerading_as_specific_student, setup_masquerade
|
||||||
from lms.djangoapps.courseware.model_data import FieldDataCache
|
from lms.djangoapps.courseware.model_data import FieldDataCache
|
||||||
from lms.djangoapps.courseware.models import BaseStudentModuleHistory, StudentModule
|
from lms.djangoapps.courseware.models import BaseStudentModuleHistory, StudentModule
|
||||||
@@ -105,7 +106,7 @@ from lms.djangoapps.courseware.user_state_client import DjangoXBlockUserStateCli
|
|||||||
from lms.djangoapps.courseware.utils import (
|
from lms.djangoapps.courseware.utils import (
|
||||||
_use_new_financial_assistance_flow,
|
_use_new_financial_assistance_flow,
|
||||||
create_financial_assistance_application,
|
create_financial_assistance_application,
|
||||||
is_eligible_for_financial_aid, unpack_jwt
|
is_eligible_for_financial_aid
|
||||||
)
|
)
|
||||||
from lms.djangoapps.edxnotes.helpers import is_feature_enabled
|
from lms.djangoapps.edxnotes.helpers import is_feature_enabled
|
||||||
from lms.djangoapps.experiments.utils import get_experiment_user_metadata_context
|
from lms.djangoapps.experiments.utils import get_experiment_user_metadata_context
|
||||||
|
|||||||
@@ -221,7 +221,6 @@ django==4.2.18
|
|||||||
# edx-search
|
# edx-search
|
||||||
# edx-submissions
|
# edx-submissions
|
||||||
# edx-toggles
|
# edx-toggles
|
||||||
# edx-token-utils
|
|
||||||
# edx-when
|
# edx-when
|
||||||
# edxval
|
# edxval
|
||||||
# enmerkar
|
# enmerkar
|
||||||
@@ -546,7 +545,7 @@ edx-when==2.5.1
|
|||||||
# edx-proctoring
|
# edx-proctoring
|
||||||
edxval==2.9.0
|
edxval==2.9.0
|
||||||
# via -r requirements/edx/kernel.in
|
# via -r requirements/edx/kernel.in
|
||||||
elasticsearch==7.9.1
|
elasticsearch==7.13.4
|
||||||
# via
|
# via
|
||||||
# -c requirements/edx/../common_constraints.txt
|
# -c requirements/edx/../common_constraints.txt
|
||||||
# -c requirements/edx/../constraints.txt
|
# -c requirements/edx/../constraints.txt
|
||||||
@@ -931,7 +930,6 @@ pygments==2.19.1
|
|||||||
pyjwkest==1.4.2
|
pyjwkest==1.4.2
|
||||||
# via
|
# via
|
||||||
# -r requirements/edx/kernel.in
|
# -r requirements/edx/kernel.in
|
||||||
# edx-token-utils
|
|
||||||
# lti-consumer-xblock
|
# lti-consumer-xblock
|
||||||
pyjwt[crypto]==2.10.1
|
pyjwt[crypto]==2.10.1
|
||||||
# via
|
# via
|
||||||
@@ -1215,7 +1213,7 @@ uritemplate==4.1.1
|
|||||||
# drf-spectacular
|
# drf-spectacular
|
||||||
# drf-yasg
|
# drf-yasg
|
||||||
# google-api-python-client
|
# google-api-python-client
|
||||||
urllib3==2.2.3
|
urllib3==1.26.20
|
||||||
# via
|
# via
|
||||||
# -c requirements/edx/../common_constraints.txt
|
# -c requirements/edx/../common_constraints.txt
|
||||||
# botocore
|
# botocore
|
||||||
|
|||||||
@@ -395,7 +395,6 @@ django==4.2.18
|
|||||||
# edx-search
|
# edx-search
|
||||||
# edx-submissions
|
# edx-submissions
|
||||||
# edx-toggles
|
# edx-toggles
|
||||||
# edx-token-utils
|
|
||||||
# edx-when
|
# edx-when
|
||||||
# edxval
|
# edxval
|
||||||
# enmerkar
|
# enmerkar
|
||||||
@@ -858,7 +857,7 @@ edxval==2.9.0
|
|||||||
# via
|
# via
|
||||||
# -r requirements/edx/doc.txt
|
# -r requirements/edx/doc.txt
|
||||||
# -r requirements/edx/testing.txt
|
# -r requirements/edx/testing.txt
|
||||||
elasticsearch==7.9.1
|
elasticsearch==7.13.4
|
||||||
# via
|
# via
|
||||||
# -c requirements/edx/../common_constraints.txt
|
# -c requirements/edx/../common_constraints.txt
|
||||||
# -c requirements/edx/../constraints.txt
|
# -c requirements/edx/../constraints.txt
|
||||||
@@ -1598,7 +1597,6 @@ pyjwkest==1.4.2
|
|||||||
# via
|
# via
|
||||||
# -r requirements/edx/doc.txt
|
# -r requirements/edx/doc.txt
|
||||||
# -r requirements/edx/testing.txt
|
# -r requirements/edx/testing.txt
|
||||||
# edx-token-utils
|
|
||||||
# lti-consumer-xblock
|
# lti-consumer-xblock
|
||||||
pyjwt[crypto]==2.10.1
|
pyjwt[crypto]==2.10.1
|
||||||
# via
|
# via
|
||||||
@@ -2172,7 +2170,7 @@ uritemplate==4.1.1
|
|||||||
# drf-spectacular
|
# drf-spectacular
|
||||||
# drf-yasg
|
# drf-yasg
|
||||||
# google-api-python-client
|
# google-api-python-client
|
||||||
urllib3==2.2.3
|
urllib3==1.26.20
|
||||||
# via
|
# via
|
||||||
# -c requirements/edx/../common_constraints.txt
|
# -c requirements/edx/../common_constraints.txt
|
||||||
# -r requirements/edx/doc.txt
|
# -r requirements/edx/doc.txt
|
||||||
|
|||||||
@@ -280,7 +280,6 @@ django==4.2.18
|
|||||||
# edx-search
|
# edx-search
|
||||||
# edx-submissions
|
# edx-submissions
|
||||||
# edx-toggles
|
# edx-toggles
|
||||||
# edx-token-utils
|
|
||||||
# edx-when
|
# edx-when
|
||||||
# edxval
|
# edxval
|
||||||
# enmerkar
|
# enmerkar
|
||||||
@@ -637,7 +636,7 @@ edx-when==2.5.1
|
|||||||
# edx-proctoring
|
# edx-proctoring
|
||||||
edxval==2.9.0
|
edxval==2.9.0
|
||||||
# via -r requirements/edx/base.txt
|
# via -r requirements/edx/base.txt
|
||||||
elasticsearch==7.9.1
|
elasticsearch==7.13.4
|
||||||
# via
|
# via
|
||||||
# -c requirements/edx/../common_constraints.txt
|
# -c requirements/edx/../common_constraints.txt
|
||||||
# -c requirements/edx/../constraints.txt
|
# -c requirements/edx/../constraints.txt
|
||||||
@@ -1147,7 +1146,6 @@ pygments==2.19.1
|
|||||||
pyjwkest==1.4.2
|
pyjwkest==1.4.2
|
||||||
# via
|
# via
|
||||||
# -r requirements/edx/base.txt
|
# -r requirements/edx/base.txt
|
||||||
# edx-token-utils
|
|
||||||
# lti-consumer-xblock
|
# lti-consumer-xblock
|
||||||
pyjwt[crypto]==2.10.1
|
pyjwt[crypto]==2.10.1
|
||||||
# via
|
# via
|
||||||
@@ -1529,7 +1527,7 @@ uritemplate==4.1.1
|
|||||||
# drf-spectacular
|
# drf-spectacular
|
||||||
# drf-yasg
|
# drf-yasg
|
||||||
# google-api-python-client
|
# google-api-python-client
|
||||||
urllib3==2.2.3
|
urllib3==1.26.20
|
||||||
# via
|
# via
|
||||||
# -c requirements/edx/../common_constraints.txt
|
# -c requirements/edx/../common_constraints.txt
|
||||||
# -r requirements/edx/base.txt
|
# -r requirements/edx/base.txt
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ edx-rest-api-client
|
|||||||
edx-search
|
edx-search
|
||||||
edx-submissions
|
edx-submissions
|
||||||
edx-toggles # Feature toggles management
|
edx-toggles # Feature toggles management
|
||||||
edx-token-utils # Validate exam access tokens
|
|
||||||
edx-when
|
edx-when
|
||||||
edxval
|
edxval
|
||||||
event-tracking
|
event-tracking
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ typing-extensions==4.12.2
|
|||||||
# opentelemetry-sdk
|
# opentelemetry-sdk
|
||||||
# referencing
|
# referencing
|
||||||
# semgrep
|
# semgrep
|
||||||
urllib3==2.2.3
|
urllib3==2.3.0
|
||||||
# via
|
# via
|
||||||
# -c requirements/edx/../common_constraints.txt
|
# -c requirements/edx/../common_constraints.txt
|
||||||
# requests
|
# requests
|
||||||
|
|||||||
@@ -306,7 +306,6 @@ django==4.2.18
|
|||||||
# edx-search
|
# edx-search
|
||||||
# edx-submissions
|
# edx-submissions
|
||||||
# edx-toggles
|
# edx-toggles
|
||||||
# edx-token-utils
|
|
||||||
# edx-when
|
# edx-when
|
||||||
# edxval
|
# edxval
|
||||||
# enmerkar
|
# enmerkar
|
||||||
@@ -660,7 +659,7 @@ edx-when==2.5.1
|
|||||||
# edx-proctoring
|
# edx-proctoring
|
||||||
edxval==2.9.0
|
edxval==2.9.0
|
||||||
# via -r requirements/edx/base.txt
|
# via -r requirements/edx/base.txt
|
||||||
elasticsearch==7.9.1
|
elasticsearch==7.13.4
|
||||||
# via
|
# via
|
||||||
# -c requirements/edx/../common_constraints.txt
|
# -c requirements/edx/../common_constraints.txt
|
||||||
# -c requirements/edx/../constraints.txt
|
# -c requirements/edx/../constraints.txt
|
||||||
@@ -1211,7 +1210,6 @@ pygments==2.19.1
|
|||||||
pyjwkest==1.4.2
|
pyjwkest==1.4.2
|
||||||
# via
|
# via
|
||||||
# -r requirements/edx/base.txt
|
# -r requirements/edx/base.txt
|
||||||
# edx-token-utils
|
|
||||||
# lti-consumer-xblock
|
# lti-consumer-xblock
|
||||||
pyjwt[crypto]==2.10.1
|
pyjwt[crypto]==2.10.1
|
||||||
# via
|
# via
|
||||||
@@ -1615,7 +1613,7 @@ uritemplate==4.1.1
|
|||||||
# drf-spectacular
|
# drf-spectacular
|
||||||
# drf-yasg
|
# drf-yasg
|
||||||
# google-api-python-client
|
# google-api-python-client
|
||||||
urllib3==2.2.3
|
urllib3==1.26.20
|
||||||
# via
|
# via
|
||||||
# -c requirements/edx/../common_constraints.txt
|
# -c requirements/edx/../common_constraints.txt
|
||||||
# -r requirements/edx/base.txt
|
# -r requirements/edx/base.txt
|
||||||
|
|||||||
@@ -14,7 +14,5 @@ idna==3.10
|
|||||||
# via requests
|
# via requests
|
||||||
requests==2.32.3
|
requests==2.32.3
|
||||||
# via -r scripts/xblock/requirements.in
|
# via -r scripts/xblock/requirements.in
|
||||||
urllib3==2.2.3
|
urllib3==2.3.0
|
||||||
# via
|
# via requests
|
||||||
# -c scripts/xblock/../../requirements/common_constraints.txt
|
|
||||||
# requests
|
|
||||||
|
|||||||
Reference in New Issue
Block a user