From 89b9203ef04af6c9b188c6de70e5256b9ad3fc7d Mon Sep 17 00:00:00 2001 From: Johan Castiblanco Date: Tue, 19 Dec 2023 16:58:04 -0500 Subject: [PATCH 1/2] 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 --- eox_tenant/pipeline.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eox_tenant/pipeline.py b/eox_tenant/pipeline.py index 6b9ec6db..e60b8aa4 100644 --- a/eox_tenant/pipeline.py +++ b/eox_tenant/pipeline.py @@ -2,8 +2,13 @@ The pipeline module defines functions that are used in the third party authentication flow """ +try: + from social_core.exceptions import AuthFailed +except ImportError: + AuthFailed = ValueError -class EoxTenantAuthException(ValueError): + +class EoxTenantAuthException(AuthFailed): """Auth process exception.""" def __init__(self, backend, *args, **kwargs): From b306762481fbf831e3730862851d5a4c79cb1620 Mon Sep 17 00:00:00 2001 From: Johan Castiblanco Date: Thu, 21 Dec 2023 11:22:18 -0500 Subject: [PATCH 2/2] refactor: social-auth-core pkg inclusion --- eox_tenant/pipeline.py | 6 +-- requirements/base.in | 1 + requirements/base.txt | 48 +++++++++++++++++++--- requirements/pip-tools.txt | 18 ++++++--- requirements/test.txt | 83 ++++++++++++++++++++++++++++++++------ requirements/tox.txt | 41 ++++++++++--------- 6 files changed, 149 insertions(+), 48 deletions(-) diff --git a/eox_tenant/pipeline.py b/eox_tenant/pipeline.py index e60b8aa4..c7739079 100644 --- a/eox_tenant/pipeline.py +++ b/eox_tenant/pipeline.py @@ -1,11 +1,7 @@ """ The pipeline module defines functions that are used in the third party authentication flow """ - -try: - from social_core.exceptions import AuthFailed -except ImportError: - AuthFailed = ValueError +from social_core.exceptions import AuthFailed class EoxTenantAuthException(AuthFailed): diff --git a/requirements/base.in b/requirements/base.in index 7260cec6..018a5d25 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -8,3 +8,4 @@ django-crum django-mysql jsonfield edx-opaque-keys[django] +social-auth-core diff --git a/requirements/base.txt b/requirements/base.txt index 1e7167bc..10953acd 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,11 +1,23 @@ # -# This file is autogenerated by pip-compile with python 3.8 +# This file is autogenerated by pip-compile with python 3.10 # To update, run: # # make upgrade # -asgiref==3.5.0 +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.7.1 + # via + # python3-openid + # social-auth-core django==3.2.15 # via # -c requirements/constraints.txt @@ -30,25 +42,49 @@ 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 -pbr==5.8.1 +oauthlib==3.2.2 + # via + # requests-oauthlib + # social-auth-core +pbr==6.0.0 # via stevedore +pycparser==2.21 + # via cffi +pyjwt==2.8.0 + # via social-auth-core pymongo==3.10.1 # via # -c requirements/constraints.txt # edx-opaque-keys -pytz==2021.3 +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 -sqlparse==0.4.2 +social-auth-core==4.5.1 + # via -r requirements/base.in +sqlparse==0.4.4 # via django -stevedore==3.5.0 +stevedore==5.1.0 # via edx-opaque-keys +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 36ddaf6a..73c737a2 100644 --- a/requirements/pip-tools.txt +++ b/requirements/pip-tools.txt @@ -1,18 +1,24 @@ # -# This file is autogenerated by pip-compile with python 3.8 +# This file is autogenerated by pip-compile with python 3.10 # To update, run: # # make upgrade # -click==8.0.4 +build==1.0.3 # via pip-tools -pep517==0.12.0 +click==8.1.7 # via pip-tools -pip-tools==6.5.1 +packaging==23.2 + # via build +pip-tools==7.3.0 # via -r requirements/pip-tools.in +pyproject-hooks==1.0.0 + # via build tomli==2.0.1 - # via pep517 -wheel==0.37.1 + # via + # build + # pip-tools +wheel==0.42.0 # via pip-tools # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/test.txt b/requirements/test.txt index f00b7d5e..887bf5e4 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,23 +1,44 @@ # -# This file is autogenerated by pip-compile with python 3.8 +# This file is autogenerated by pip-compile with python 3.10 # To update, run: # # make upgrade # -asgiref==3.5.0 +asgiref==3.7.2 # via # -r requirements/base.txt # django astroid==2.9.3 # 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[toml]==6.0.2 # via # -c requirements/constraints.txt # -r requirements/test.in +cryptography==41.0.7 + # via + # -r requirements/base.txt + # social-auth-core ddt==1.4.4 # via # -c requirements/constraints.txt # -r requirements/test.in +defusedxml==0.7.1 + # via + # -r requirements/base.txt + # python3-openid + # social-auth-core # via # -c requirements/constraints.txt # -r requirements/base.txt @@ -45,13 +66,17 @@ edx-opaque-keys[django]==2.3.0 # via # -c requirements/constraints.txt # -r requirements/base.txt -isort==5.10.1 +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.7.1 +lazy-object-proxy==1.10.0 # via astroid mccabe==0.6.1 # via pylint @@ -59,22 +84,35 @@ mock==4.0.3 # via # -c requirements/constraints.txt # -r requirements/test.in -path==16.4.0 +oauthlib==3.2.2 + # via + # -r requirements/base.txt + # requests-oauthlib + # social-auth-core +path==16.9.0 # via path-py path-py==12.5.0 # via # -c requirements/constraints.txt # -r requirements/test.in -pbr==5.8.1 +pbr==6.0.0 # via # -r requirements/base.txt # stevedore -platformdirs==2.5.1 +platformdirs==4.1.0 # via pylint pycodestyle==2.8.0 # via # -c requirements/constraints.txt # -r requirements/test.in +pycparser==2.21 + # via + # -r requirements/base.txt + # cffi +pyjwt==2.8.0 + # via + # -r requirements/base.txt + # social-auth-core pylint==2.12.2 # via # -c requirements/constraints.txt @@ -84,20 +122,35 @@ pymongo==3.10.1 # -c requirements/constraints.txt # -r requirements/base.txt # edx-opaque-keys -pytz==2021.3 +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 -sqlparse==0.4.2 +social-auth-core==4.5.1 + # via -r requirements/base.txt +sqlparse==0.4.4 # via # -r requirements/base.txt # django -stevedore==3.5.0 +stevedore==5.1.0 # via # -r requirements/base.txt # edx-opaque-keys @@ -109,10 +162,14 @@ toml==0.10.2 # via pylint tomli==2.0.1 # via coverage -typing-extensions==4.1.1 +typing-extensions==4.9.0 # via - # astroid - # pylint + # -r requirements/base.txt + # asgiref +urllib3==2.1.0 + # via + # -r requirements/base.txt + # requests wrapt==1.13.3 # via astroid diff --git a/requirements/tox.txt b/requirements/tox.txt index 74fc0739..efd61e2c 100644 --- a/requirements/tox.txt +++ b/requirements/tox.txt @@ -1,33 +1,38 @@ # -# This file is autogenerated by pip-compile with python 3.8 +# This file is autogenerated by pip-compile with python 3.10 # To update, run: # # make upgrade # -distlib==0.3.4 +cachetools==5.3.2 + # via tox +chardet==5.2.0 + # via tox +colorama==0.4.6 + # via tox +distlib==0.3.8 # via virtualenv -filelock==3.6.0 +filelock==3.13.1 # via # tox # virtualenv -packaging==21.3 - # via tox -platformdirs==2.5.1 - # via virtualenv -pluggy==1.0.0 - # via tox -py==1.11.0 - # via tox -pyparsing==3.0.7 - # via packaging -six==1.16.0 +packaging==23.2 + # via + # pyproject-api + # tox +platformdirs==4.1.0 # via - # -c requirements/constraints.txt # tox # virtualenv -toml==0.10.2 +pluggy==1.3.0 # via tox -tox==3.24.5 +pyproject-api==1.6.1 + # via tox +tomli==2.0.1 + # via + # pyproject-api + # tox +tox==4.11.4 # via -r requirements/tox.in -virtualenv==20.13.2 +virtualenv==20.25.0 # via tox