From 03770b37f66614ad48149ec461bfc77584d095a5 Mon Sep 17 00:00:00 2001 From: Greg Werner Date: Fri, 29 Oct 2021 02:54:06 -0400 Subject: [PATCH] fix: Update LTIAuthenticator setup course hook (#626) --- .../authenticators/authenticator.py | 17 +- src/illumidesk/requirements.txt | 449 ++++-------------- src/illumidesk/setup.py | 9 +- 3 files changed, 113 insertions(+), 362 deletions(-) diff --git a/src/illumidesk/illumidesk/authenticators/authenticator.py b/src/illumidesk/illumidesk/authenticators/authenticator.py index dfc4267a..6104ba9e 100644 --- a/src/illumidesk/illumidesk/authenticators/authenticator.py +++ b/src/illumidesk/illumidesk/authenticators/authenticator.py @@ -29,8 +29,13 @@ raise EnvironmentError("ORGANIZATION_NAME env-var is not set") +class AddJupyterHubUserException(Exception): + """Custom exception that is raised when adding a user to the JupyterHub database.""" + + pass + + async def setup_course_hook_lti11( - self, handler: RequestHandler, authentication: Dict[str, str], ) -> Dict[str, str]: @@ -56,7 +61,7 @@ async def setup_course_hook_lti11( # normalize the name and course_id strings in authentication dictionary username = authentication["name"] - lms_user_id = authentication["auth_state"]["lms_user_id"] + lms_user_id = authentication["auth_state"]["user_id"] user_role = authentication["auth_state"]["roles"].split(",")[0] course_id = lti_utils.normalize_string( authentication["auth_state"]["context_label"] @@ -70,7 +75,7 @@ async def setup_course_hook_lti11( try: # assign the user to 'nbgrader-' group in jupyterhub and gradebook await jupyterhub_api.add_student_to_jupyterhub_group(course_id, username) - except Exception as e: + except AddJupyterHubUserException as e: logger.error( "An error when adding student username: %s to course_id: %s with exception %s", (username, course_id, e), @@ -79,7 +84,7 @@ async def setup_course_hook_lti11( try: # assign the user in 'formgrade-' group await jupyterhub_api.add_instructor_to_jupyterhub_group(course_id, username) - except Exception as e: + except AddJupyterHubUserException as e: logger.error( "An error when adding instructor username: %s to course_id: %s with exception %s", (username, course_id, e), @@ -134,7 +139,7 @@ async def setup_course_hook( try: # assign the user to 'nbgrader-' group in jupyterhub and gradebook await jupyterhub_api.add_student_to_jupyterhub_group(course_id, username) - except Exception as e: + except AddJupyterHubUserException as e: logger.error( "An error when adding student username: %s to course_id: %s with exception %s", (username, course_id, e), @@ -143,7 +148,7 @@ async def setup_course_hook( try: # assign the user in 'formgrade-' group await jupyterhub_api.add_instructor_to_jupyterhub_group(course_id, username) - except Exception as e: + except AddJupyterHubUserException as e: logger.error( "An error when adding instructor username: %s to course_id: %s with exception %s", (username, course_id, e), diff --git a/src/illumidesk/requirements.txt b/src/illumidesk/requirements.txt index 899790e0..adcc69e4 100644 --- a/src/illumidesk/requirements.txt +++ b/src/illumidesk/requirements.txt @@ -2,357 +2,106 @@ # This file is autogenerated by pip-compile # To update, run: # -# pip-compile setup.py +# pip-compile # -alembic==1.6.2 - # via - # jupyterhub - # nbgrader -argon2-cffi==20.1.0 - # via notebook -async-generator==1.10 - # via - # jupyterhub - # jupyterhub-kubespawner -attrs==21.2.0 - # via jsonschema -backcall==0.2.0 - # via ipython -bleach==3.3.0 - # via nbconvert -cachetools==4.2.2 - # via google-auth -certifi==2020.12.5 - # via - # kubernetes - # requests -certipy==0.1.3 - # via jupyterhub -cffi==1.14.5 - # via - # argon2-cffi - # cryptography -chardet==4.0.0 - # via requests -cryptography==3.4.7 - # via - # josepy - # jwcrypto - # pyopenssl -decorator==5.0.9 - # via - # ipython - # traitlets -defusedxml==0.7.1 - # via nbconvert -entrypoints==0.3 - # via - # jupyterhub - # nbconvert -escapism==1.0.1 - # via jupyterhub-kubespawner -filelock==3.0.12 - # via illumidesk (setup.py) -future==0.18.2 - # via pyjwkest -google-auth==1.30.0 - # via kubernetes -greenlet==1.1.0 - # via sqlalchemy -httplib2==0.19.1 - # via - # oauth2 - # pylti -idna==2.10 - # via requests -ipykernel==5.5.5 - # via - # ipywidgets - # jupyter - # jupyter-console - # notebook - # qtconsole -ipython-genutils==0.2.0 - # via - # nbformat - # notebook - # qtconsole - # traitlets -ipython==7.23.1 - # via - # ipykernel - # ipywidgets - # jupyter-console -ipywidgets==7.6.3 - # via jupyter -jedi==0.18.0 - # via ipython -jinja2==3.0.0 - # via - # jupyterhub - # jupyterhub-kubespawner - # nbconvert - # notebook -josepy==1.4.0 - # via illumidesk (setup.py) -jsonschema==3.2.0 - # via - # jupyter-telemetry - # nbformat - # nbgrader -jupyter-client==6.1.12 - # via - # ipykernel - # jupyter-console - # nbgrader - # notebook - # qtconsole -jupyter-console==6.4.0 - # via jupyter -jupyter-core==4.7.1 - # via - # jupyter-client - # nbconvert - # nbformat - # nbgrader - # notebook - # qtconsole -jupyter-telemetry==0.1.0 - # via jupyterhub -jupyter==1.0.0 - # via nbgrader -jupyterhub-kubespawner==0.14.1 - # via illumidesk (setup.py) -jupyterhub-ltiauthenticator==1.0.0 - # via illumidesk (setup.py) -jupyterhub==1.4.1 - # via - # illumidesk (setup.py) - # jupyterhub-kubespawner - # jupyterhub-ltiauthenticator - # oauthenticator -jupyterlab-widgets==1.0.0 - # via ipywidgets -jwcrypto==0.8 - # via illumidesk (setup.py) -kubernetes==17.17.0 - # via jupyterhub-kubespawner -lti==0.9.5 - # via illumidesk (setup.py) -lxml==4.6.3 - # via lti -mako==1.1.4 - # via alembic -markupsafe==2.0.0 - # via - # jinja2 - # mako -matplotlib-inline==0.1.2 - # via ipython -mistune==0.8.4 - # via nbconvert -nbconvert==5.6.1 - # via - # jupyter - # nbgrader - # notebook -nbformat==5.1.3 - # via - # ipywidgets - # nbconvert - # nbgrader - # notebook -git+https://github.com/IllumiDesk/nbgrader.git@v0.64.3#egg=nbgrader - # via illumidesk (setup.py) -notebook==6.3.0 - # via - # jupyter - # nbgrader - # widgetsnbextension -oauth2==1.9.0.post1 - # via pylti -oauthenticator==0.11.0 - # via illumidesk (setup.py) -oauthlib==3.1.0 - # via - # jupyterhub - # jupyterhub-ltiauthenticator - # lti - # requests-oauthlib -packaging==20.9 - # via bleach -pamela==1.0.0 - # via jupyterhub -pandocfilters==1.4.3 - # via nbconvert -parso==0.8.2 - # via jedi -pem==20.1.0 - # via illumidesk (setup.py) -pexpect==4.8.0 - # via ipython -pickleshare==0.7.5 - # via ipython -prometheus-client==0.10.1 - # via - # jupyterhub - # notebook -prompt-toolkit==3.0.18 - # via - # ipython - # jupyter-console -psycopg2-binary==2.8.6 - # via illumidesk (setup.py) -ptyprocess==0.7.0 - # via - # pexpect - # terminado -pyasn1-modules==0.2.8 - # via google-auth -pyasn1==0.4.8 - # via - # pyasn1-modules - # rsa -pycparser==2.20 - # via cffi -pycryptodome==3.9.8 - # via illumidesk (setup.py) -pycryptodomex==3.10.1 - # via pyjwkest -pygments==2.9.0 - # via - # ipython - # jupyter-console - # nbconvert - # qtconsole -pyjwkest==1.4.2 - # via illumidesk (setup.py) -pyjwt==1.7.1 - # via illumidesk (setup.py) -pylti==0.7.0 - # via illumidesk (setup.py) -pyopenssl==20.0.1 - # via - # certipy - # josepy -pyparsing==2.4.7 - # via - # httplib2 - # packaging -pyrsistent==0.17.3 - # via jsonschema -python-dateutil==2.8.1 - # via - # alembic - # jupyter-client - # jupyterhub - # kubernetes - # nbgrader -python-editor==1.0.4 - # via alembic -python-json-logger==2.0.1 - # via jupyter-telemetry -python-slugify==5.0.2 - # via jupyterhub-kubespawner -pyyaml==5.4.1 - # via - # jupyterhub-kubespawner - # kubernetes -pyzmq==22.0.3 - # via - # jupyter-client - # notebook - # qtconsole -qtconsole==5.1.0 - # via jupyter -qtpy==1.9.0 - # via qtconsole -rapidfuzz==1.4.1 - # via nbgrader -requests-oauthlib==1.3.0 - # via - # kubernetes - # lti -requests==2.25.1 - # via - # jupyterhub - # kubernetes - # nbgrader - # pyjwkest - # requests-oauthlib -rsa==4.7.2 - # via google-auth -ruamel.yaml.clib==0.2.2 - # via ruamel.yaml -ruamel.yaml==0.17.4 - # via jupyter-telemetry -send2trash==1.5.0 - # via notebook -six==1.16.0 - # via - # argon2-cffi - # bleach - # google-auth - # josepy - # jsonschema - # kubernetes - # pyjwkest - # pylti - # pyopenssl - # python-dateutil - # sqlalchemy-utils - # traitlets - # websocket-client -sqlalchemy-utils==0.36.8 - # via illumidesk (setup.py) -sqlalchemy==1.4.15 - # via - # alembic - # jupyterhub - # nbgrader - # sqlalchemy-utils -terminado==0.9.5 - # via notebook -testpath==0.4.4 - # via nbconvert -text-unidecode==1.3 - # via python-slugify -tornado==6.1 - # via - # ipykernel - # jupyter-client - # jupyterhub - # nbgrader - # notebook - # terminado -traitlets==4.3.3 - # via - # ipykernel - # ipython - # ipywidgets - # jupyter-client - # jupyter-core - # jupyter-telemetry - # jupyterhub - # matplotlib-inline - # nbconvert - # nbformat - # nbgrader - # notebook - # qtconsole -urllib3==1.26.5 - # via - # jupyterhub-kubespawner - # kubernetes - # requests -wcwidth==0.2.5 - # via prompt-toolkit -webencodings==0.5.1 - # via bleach -websocket-client==0.59.0 - # via kubernetes -widgetsnbextension==3.5.1 - # via ipywidgets +alembic==1.6.2 # via jupyterhub, nbgrader +argon2-cffi==20.1.0 # via notebook +async-generator==1.10 # via jupyterhub, jupyterhub-kubespawner +attrs==21.2.0 # via jsonschema +backcall==0.2.0 # via ipython +bleach==3.3.0 # via nbconvert +cachetools==4.2.2 # via google-auth +certifi==2020.12.5 # via kubernetes, requests +certipy==0.1.3 # via jupyterhub +cffi==1.14.5 # via argon2-cffi, cryptography +chardet==4.0.0 # via requests +cryptography==3.4.7 # via josepy, jwcrypto, pyopenssl +decorator==5.0.9 # via ipython, traitlets +defusedxml==0.7.1 # via nbconvert +entrypoints==0.3 # via jupyterhub, nbconvert +escapism==1.0.1 # via jupyterhub-kubespawner, jupyterhub-ltiauthenticator +future==0.18.2 # via pyjwkest +google-auth==1.30.0 # via kubernetes +idna==2.10 # via requests +ipykernel==5.5.5 # via ipywidgets, jupyter, jupyter-console, notebook, qtconsole +ipython-genutils==0.2.0 # via nbformat, notebook, qtconsole, traitlets +ipython==7.23.1 # via ipykernel, ipywidgets, jupyter-console +ipywidgets==7.6.3 # via jupyter +jedi==0.18.0 # via ipython +jinja2==3.0.0 # via jupyterhub, jupyterhub-kubespawner, nbconvert, notebook +josepy==1.4.0 # via illumidesk (setup.py) +jsonschema==3.2.0 # via jupyter-telemetry, nbformat, nbgrader +jupyter-client==6.1.12 # via ipykernel, jupyter-console, nbgrader, notebook, qtconsole +jupyter-console==6.4.0 # via jupyter +jupyter-core==4.7.1 # via jupyter-client, nbconvert, nbformat, nbgrader, notebook, qtconsole +jupyter-telemetry==0.1.0 # via jupyterhub +jupyter==1.0.0 # via nbgrader +jupyterhub-kubespawner==0.14.1 # via illumidesk (setup.py) +git+git://github.com/jupyterhub/ltiauthenticator.git@71d86a9da2562df4bdcc9f374af834a172ac52d5 # via illumidesk (setup.py) +jupyterhub==1.4.1 # via jupyterhub-kubespawner, jupyterhub-ltiauthenticator, oauthenticator +jupyterlab-widgets==1.0.0 # via ipywidgets +jwcrypto==0.8 # via illumidesk (setup.py) +kubernetes==17.17.0 # via jupyterhub-kubespawner +mako==1.1.4 # via alembic +markupsafe==2.0.0 # via jinja2, mako +matplotlib-inline==0.1.2 # via ipython +mistune==0.8.4 # via nbconvert +nbconvert==5.6.1 # via jupyter, nbgrader, notebook +nbformat==5.1.3 # via ipywidgets, nbconvert, nbgrader, notebook +nbgrader==0.6.2 # via illumidesk (setup.py) +notebook==6.3.0 # via jupyter, nbgrader, widgetsnbextension +oauthenticator==14.2.0 # via illumidesk (setup.py) +oauthlib==3.1.0 # via illumidesk (setup.py), jupyterhub, jupyterhub-ltiauthenticator, requests-oauthlib +packaging==20.9 # via bleach +pamela==1.0.0 # via jupyterhub +pandocfilters==1.4.3 # via nbconvert +parso==0.8.2 # via jedi +pem==20.1.0 # via illumidesk (setup.py) +pexpect==4.8.0 # via ipython +pickleshare==0.7.5 # via ipython +prometheus-client==0.10.1 # via jupyterhub, notebook +prompt-toolkit==3.0.18 # via ipython, jupyter-console +psycopg2-binary==2.8.6 # via illumidesk (setup.py) +ptyprocess==0.7.0 # via pexpect, terminado +pyasn1-modules==0.2.8 # via google-auth +pyasn1==0.4.8 # via pyasn1-modules, rsa +pycparser==2.20 # via cffi +pycryptodome==3.9.8 # via illumidesk (setup.py) +pycryptodomex==3.10.1 # via pyjwkest +pygments==2.9.0 # via ipython, jupyter-console, nbconvert, qtconsole +pyjwkest==1.4.2 # via illumidesk (setup.py) +pyjwt==1.7.1 # via illumidesk (setup.py) +pyopenssl==20.0.1 # via certipy, josepy +pyparsing==2.4.7 # via packaging +pyrsistent==0.17.3 # via jsonschema +python-dateutil==2.8.1 # via alembic, jupyter-client, jupyterhub, kubernetes, nbgrader +python-editor==1.0.4 # via alembic +python-json-logger==2.0.1 # via jupyter-telemetry +python-slugify==5.0.2 # via jupyterhub-kubespawner +pyyaml==5.4.1 # via jupyterhub-kubespawner, kubernetes +pyzmq==22.0.3 # via jupyter-client, notebook, qtconsole +qtconsole==5.1.0 # via jupyter +qtpy==1.9.0 # via qtconsole +rapidfuzz==1.4.1 # via nbgrader +requests-oauthlib==1.3.0 # via kubernetes +requests==2.25.1 # via jupyterhub, kubernetes, nbgrader, pyjwkest, requests-oauthlib +rsa==4.7.2 # via google-auth +ruamel.yaml.clib==0.2.2 # via ruamel.yaml +ruamel.yaml==0.17.4 # via jupyter-telemetry +send2trash==1.5.0 # via notebook +six==1.16.0 # via argon2-cffi, bleach, google-auth, josepy, jsonschema, kubernetes, nbgrader, pyjwkest, pyopenssl, python-dateutil, sqlalchemy-utils, traitlets, websocket-client +sqlalchemy-utils==0.36.8 # via illumidesk (setup.py) +sqlalchemy==1.3.24 # via alembic, jupyterhub, nbgrader, sqlalchemy-utils +terminado==0.9.5 # via notebook +testpath==0.4.4 # via nbconvert +text-unidecode==1.3 # via python-slugify +tornado==6.1 # via ipykernel, jupyter-client, jupyterhub, nbgrader, notebook, terminado +traitlets==4.3.3 # via ipykernel, ipython, ipywidgets, jupyter-client, jupyter-core, jupyter-telemetry, jupyterhub, matplotlib-inline, nbconvert, nbformat, nbgrader, notebook, qtconsole +urllib3==1.26.5 # via jupyterhub-kubespawner, kubernetes, requests +wcwidth==0.2.5 # via prompt-toolkit +webencodings==0.5.1 # via bleach +websocket-client==0.59.0 # via kubernetes +widgetsnbextension==3.5.1 # via ipywidgets # The following packages are considered to be unsafe in a requirements file: # setuptools diff --git a/src/illumidesk/setup.py b/src/illumidesk/setup.py index 59ba4df7..15716912 100644 --- a/src/illumidesk/setup.py +++ b/src/illumidesk/setup.py @@ -36,21 +36,18 @@ license="Apache 2.0", packages=find_packages(exclude="./tests"), install_requires=[ - "filelock==3.0.12", "josepy==1.4.0", - "jupyterhub==1.4.1", "jupyterhub-kubespawner==0.14.1", - "jupyterhub-ltiauthenticator@git+git://github.com/jupyterhub/ltiauthenticator.git@01009c50834771acf124b505cf9ba5269f75238a", + "jupyterhub-ltiauthenticator@git+git://github.com/jupyterhub/ltiauthenticator.git@71d86a9da2562df4bdcc9f374af834a172ac52d5", "jwcrypto==0.8", - "lti==0.9.5", "nbgrader==0.6.2", - "oauthenticator==0.11.0", + "oauthlib==3.1", + "oauthenticator>=0.13.0", "pem==20.1.0", "psycopg2-binary==2.8.6", "PyJWT==1.7.1", "pyjwkest==1.4.2", "pycryptodome==3.9.8", - "pylti==0.7.0", "SQLAlchemy-Utils==0.36.8", ], # noqa: E231 package_data={