From ac07a9a902cd4668ab35f577b644d88ca18cf213 Mon Sep 17 00:00:00 2001 From: Johan Seto K <51926076+johanseto@users.noreply.github.com> Date: Thu, 4 Jan 2024 15:05:13 -0500 Subject: [PATCH] refactor: inherit from social auth exception * refactor: inherit from social auth exception This change the heritance of the eox-tenant-auth-exception. This with the purpose of the exception to be handled by the social tpa middleware exception process. You can see here that the new class is also based in value error exception. https://github.com/python-social-auth/social-core/blob/29cbbd22b98d81d569a886b1cc0bd9a316cd124f/social_core/exceptions.py#L1 But the change is related with this PR: https://github.com/eduNEXT/eox-core/pull/171 So now as the exception is family of the SocialAuthBaseException. The the tpa middleware could managed it. https://github.com/python-social-auth/social-app-django/blob/5.4.0/social_django/middleware.py#L35 Keep in mind that this middleware is parent of edx-platform middleware. https://github.com/openedx/edx-platform/blob/ebcbe1cd9208191c0589d7fe538c6ac13470abe6/common/djangoapps/third_party_auth/middleware.py#L18 * refactor: social-auth-core pkg inclusion (cherry picked from commit c542749eceab893ec351cfd7a056f679de760d26) --- eox_tenant/pipeline.py | 3 +- requirements/base.in | 1 + requirements/base.txt | 38 +++++++++++++++++- requirements/pip-tools.txt | 4 +- requirements/test.txt | 81 ++++++++++++++++++++++++++++++++------ requirements/tox.txt | 8 ++-- 6 files changed, 114 insertions(+), 21 deletions(-) diff --git a/eox_tenant/pipeline.py b/eox_tenant/pipeline.py index 6b9ec6db..c7739079 100644 --- a/eox_tenant/pipeline.py +++ b/eox_tenant/pipeline.py @@ -1,9 +1,10 @@ """ The pipeline module defines functions that are used in the third party authentication flow """ +from social_core.exceptions import AuthFailed -class EoxTenantAuthException(ValueError): +class EoxTenantAuthException(AuthFailed): """Auth process exception.""" def __init__(self, backend, *args, **kwargs): diff --git a/requirements/base.in b/requirements/base.in index 33396059..5e06a789 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -9,3 +9,4 @@ django-mysql jsonfield edx-opaque-keys[django] openedx_filters +social-auth-core diff --git a/requirements/base.txt b/requirements/base.txt index f3e88ef7..756d42cc 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -6,6 +6,18 @@ # asgiref==3.7.2 # via django +certifi==2023.11.17 + # via requests +cffi==1.16.0 + # via cryptography +charset-normalizer==3.3.2 + # via requests +cryptography==41.0.7 + # via social-auth-core +defusedxml==0.8.0rc2 + # via + # python3-openid + # social-auth-core django==3.2.23 # via # -c requirements/constraints.txt @@ -19,7 +31,7 @@ django-crum==0.7.9 # via # -c requirements/constraints.txt # -r requirements/base.in -django-mysql==4.7.1 +django-mysql==4.9.0 # via # -c requirements/constraints.txt # -r requirements/base.in @@ -31,31 +43,53 @@ edx-opaque-keys[django]==2.3.0 # via # -c requirements/constraints.txt # -r requirements/base.in +idna==3.6 + # via requests jsonfield==3.1.0 # via # -c requirements/constraints.txt # -r requirements/base.in +oauthlib==3.2.2 + # via + # requests-oauthlib + # social-auth-core openedx-filters==1.2.0 # via # -c requirements/constraints.txt # -r requirements/base.in pbr==6.0.0 # via stevedore +pycparser==2.21 + # via cffi +pyjwt==2.8.0 + # via social-auth-core pymongo==3.13.0 # via # -c requirements/constraints.txt # edx-opaque-keys +python3-openid==3.2.0 + # via social-auth-core pytz==2023.3.post1 # via # django # djangorestframework +requests==2.31.0 + # via + # requests-oauthlib + # social-auth-core +requests-oauthlib==1.3.1 + # via social-auth-core six==1.16.0 # via # -c requirements/constraints.txt # -r requirements/base.in +social-auth-core==4.5.1 + # via -r requirements/base.in sqlparse==0.4.4 # via django stevedore==5.1.0 # via edx-opaque-keys -typing-extensions==4.8.0 +typing-extensions==4.9.0 # via asgiref +urllib3==2.1.0 + # via requests diff --git a/requirements/pip-tools.txt b/requirements/pip-tools.txt index ea347319..0e882265 100644 --- a/requirements/pip-tools.txt +++ b/requirements/pip-tools.txt @@ -8,7 +8,7 @@ build==1.0.3 # via pip-tools click==8.1.7 # via pip-tools -importlib-metadata==6.8.0 +importlib-metadata==7.0.1 # via build packaging==23.2 # via build @@ -21,7 +21,7 @@ tomli==2.0.1 # build # pip-tools # pyproject-hooks -wheel==0.41.3 +wheel==0.42.0 # via pip-tools zipp==3.17.0 # via importlib-metadata diff --git a/requirements/test.txt b/requirements/test.txt index 40abf287..0d77a8f4 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -8,16 +8,37 @@ asgiref==3.7.2 # via # -r requirements/base.txt # django -astroid==2.11.7 +astroid==2.15.8 # via pylint +certifi==2023.11.17 + # via + # -r requirements/base.txt + # requests +cffi==1.16.0 + # via + # -r requirements/base.txt + # cryptography +charset-normalizer==3.3.2 + # via + # -r requirements/base.txt + # requests coverage==6.5.0 # via # -c requirements/constraints.txt # -r requirements/test.in +cryptography==41.0.7 + # via + # -r requirements/base.txt + # social-auth-core ddt==1.6.0 # via # -c requirements/constraints.txt # -r requirements/test.in +defusedxml==0.8.0rc2 + # via + # -r requirements/base.txt + # python3-openid + # social-auth-core dill==0.3.7 # via pylint # via @@ -36,7 +57,7 @@ django-fake-model==0.1.4 # via # -c requirements/constraints.txt # -r requirements/test.in -django-mysql==4.7.1 +django-mysql==4.9.0 # via # -c requirements/constraints.txt # -r requirements/base.txt @@ -48,25 +69,35 @@ edx-opaque-keys[django]==2.3.0 # via # -c requirements/constraints.txt # -r requirements/base.txt -isort==5.12.0 + # edx-opaque-keys +idna==3.6 + # via + # -r requirements/base.txt + # requests +isort==5.13.2 # via pylint jsonfield==3.1.0 # via # -c requirements/constraints.txt # -r requirements/base.txt -lazy-object-proxy==1.9.0 +lazy-object-proxy==1.10.0 # via astroid mccabe==0.7.0 # via pylint -mock==4.0.3 +mock==5.0.2 # via # -c requirements/constraints.txt # -r requirements/test.in +oauthlib==3.2.2 + # via + # -r requirements/base.txt + # requests-oauthlib + # social-auth-core openedx-filters==1.2.0 # via # -c requirements/constraints.txt # -r requirements/base.txt -path==16.7.1 +path==16.9.0 # via path-py path-py==12.5.0 # via @@ -76,13 +107,21 @@ pbr==6.0.0 # via # -r requirements/base.txt # stevedore -platformdirs==4.0.0 +platformdirs==4.1.0 # via pylint pycodestyle==2.8.0 # via # -c requirements/constraints.txt # -r requirements/test.in -pylint==2.13.9 +pycparser==2.21 + # via + # -r requirements/base.txt + # cffi +pyjwt==2.8.0 + # via + # -r requirements/base.txt + # social-auth-core +pylint==2.17.7 # via # -c requirements/constraints.txt # -r requirements/test.in @@ -91,15 +130,30 @@ pymongo==3.13.0 # -c requirements/constraints.txt # -r requirements/base.txt # edx-opaque-keys +python3-openid==3.2.0 + # via + # -r requirements/base.txt + # social-auth-core pytz==2023.3.post1 # via # -r requirements/base.txt # django # djangorestframework +requests==2.31.0 + # via + # -r requirements/base.txt + # requests-oauthlib + # social-auth-core +requests-oauthlib==1.3.1 + # via + # -r requirements/base.txt + # social-auth-core six==1.16.0 # via # -c requirements/constraints.txt # -r requirements/base.txt +social-auth-core==4.5.1 + # via -r requirements/base.txt sqlparse==0.4.4 # via # -r requirements/base.txt @@ -114,14 +168,17 @@ testfixtures==7.0.0 # -r requirements/test.in tomli==2.0.1 # via pylint -typing-extensions==4.8.0 +tomlkit==0.12.3 + # via pylint +typing-extensions==4.9.0 # via # -r requirements/base.txt # asgiref # astroid # pylint +urllib3==2.1.0 + # via + # -r requirements/base.txt + # requests wrapt==1.16.0 # via astroid - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/requirements/tox.txt b/requirements/tox.txt index 46856718..58a57dde 100644 --- a/requirements/tox.txt +++ b/requirements/tox.txt @@ -10,7 +10,7 @@ chardet==5.2.0 # via tox colorama==0.4.6 # via tox -distlib==0.3.7 +distlib==0.3.8 # via virtualenv filelock==3.13.1 # via @@ -20,7 +20,7 @@ packaging==23.2 # via # pyproject-api # tox -platformdirs==3.11.0 +platformdirs==4.1.0 # via # tox # virtualenv @@ -32,7 +32,7 @@ tomli==2.0.1 # via # pyproject-api # tox -tox==4.11.3 +tox==4.11.4 # via -r requirements/tox.in -virtualenv==20.24.6 +virtualenv==20.25.0 # via tox