Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to access their Magpie cookie programmatically #407

Merged
merged 8 commits into from
Dec 7, 2023

Conversation

mishaschwartz
Copy link
Collaborator

@mishaschwartz mishaschwartz commented Nov 30, 2023

Overview

When the user logs in to jupyterhub, their Magpie cookie is stored in the jupyterhub database. This allows the user to access this variable to programmatically access resources protected by magpie without having to copy/paste these cookies from their browser session or add a username and password in plaintext to the file.

For example, to access a dataset behind a secured URL with xarray.open_dataset using a username and password:

import requests
from request_magpie import MagpieAuth
import xarray

with requests.session() as session:
     session.auth = MagpieAuth("https://mynode/magpie", "myusername", "myverysecretpassword")
     store = xarray.backends.PydapDataStore.open("https://mynode/thredds/some/secure/dataset.nc", session=session)
     dataset = xarray.open_dataset(store)

And to do the same thing using the current magpie cookie already used to log in the current user (no need to include username and password)

import os
import requests
import xarray

with requests.session() as session:
    r = requests.get(f"{os.getenv('JUPYTERHUB_API_URL')}/users/{os.getenv('JUPYTERHUB_USER')}", 
                     headers={"Authorization": f"token {os.getenv('JUPYTERHUB_API_TOKEN')}"})
    for name, value in r.json().get("auth_state", {}).get("magpie_cookies", {}).items():
        session.cookies.set(name, value)
    store = xarray.backends.PydapDataStore.open("https://mynode/thredds/some/secure/dataset.nc", session=session)
    dataset = xarray.open_dataset(store)        

Note that users who are already logged in to jupyterhub will need to log out and log in for these changes to take effect.

Changes

Non-breaking changes

  • New component version jupyterhub:4.0.2-20231130

Breaking changes

  • None

Related Issue / Discussion

Additional Information

birdhouse_daccs_configs_branch: master
birdhouse_skip_ci: false

@github-actions github-actions bot added component/jupyterhub Related to JupyterHub as development frontend with notebooks documentation Improvements or additions to documentation labels Nov 30, 2023
@crim-jenkins-bot
Copy link
Collaborator

E2E Test Results

DACCS-iac Pipeline Results

Build URL : http://daccs-jenkins.crim.ca:80/job/DACCS-iac-birdhouse/2320/
Result : success

BIRDHOUSE_DEPLOY_BRANCH : add-magpie-cookie-as-env-var
DACCS_CONFIGS_BRANCH : master
PAVICS_E2E_WORKFLOW_TESTS_BRANCH : master
PAVICS_SDI_BRANCH : master

DESTROY_INFRA_ON_EXIT : true
PAVICS_HOST : https://host-140-133.rdext.crim.ca

PAVICS-e2e-workflow-tests Pipeline Results

Tests URL : http://daccs-jenkins.crim.ca:80/job/PAVICS-e2e-workflow-tests/job/master/1449/

NOTEBOOK TEST RESULTS
    
[2023-11-30T16:13:38.025Z] ============================= test session starts ==============================
[2023-11-30T16:13:38.025Z] platform linux -- Python 3.9.16, pytest-7.3.1, pluggy-1.0.0
[2023-11-30T16:13:38.025Z] rootdir: /home/jenkins/agent/workspace/PAVICS-e2e-workflow-tests_master
[2023-11-30T16:13:38.025Z] plugins: anyio-3.6.1, dash-2.10.0, nbval-0.9.6, tornasync-0.6.0.post2, xdist-3.3.1
[2023-11-30T16:13:38.025Z] collected 255 items
[2023-11-30T16:13:38.025Z] 
[2023-11-30T16:13:48.808Z] notebooks-auth/geoserver.ipynb ..................                        [  7%]
[2023-11-30T16:13:57.535Z] notebooks-auth/test_thredds.ipynb ...........                            [ 11%]
[2023-11-30T16:14:06.479Z] pavics-sdi-master/docs/source/notebooks/WCS_example.ipynb .......        [ 14%]
[2023-11-30T16:14:16.567Z] pavics-sdi-master/docs/source/notebooks/WFS_example.ipynb ......         [ 16%]
[2023-11-30T16:14:23.775Z] pavics-sdi-master/docs/source/notebooks/WMS_example.ipynb ........       [ 19%]
[2023-11-30T16:26:42.027Z] pavics-sdi-master/docs/source/notebooks/climex.ipynb ............        [ 24%]
[2023-11-30T16:26:42.027Z] pavics-sdi-master/docs/source/notebooks/eccc-geoapi-climate-stations.ipynb . [ 24%]
[2023-11-30T16:26:51.936Z] ...............                                                          [ 30%]
[2023-11-30T16:27:04.105Z] pavics-sdi-master/docs/source/notebooks/eccc-geoapi-xclim.ipynb .....    [ 32%]
[2023-11-30T16:27:11.162Z] pavics-sdi-master/docs/source/notebooks/esgf-dap.ipynb ......            [ 34%]
[2023-11-30T16:27:27.630Z] pavics-sdi-master/docs/source/notebooks/forecasts.ipynb ......           [ 37%]
[2023-11-30T16:27:29.015Z] pavics-sdi-master/docs/source/notebooks/jupyter_extensions.ipynb .       [ 37%]
[2023-11-30T16:27:34.808Z] pavics-sdi-master/docs/source/notebooks/opendap.ipynb .......            [ 40%]
[2023-11-30T16:27:40.292Z] pavics-sdi-master/docs/source/notebooks/pavics_thredds.ipynb .....       [ 42%]
[2023-11-30T16:31:25.222Z] pavics-sdi-master/docs/source/notebooks/regridding.ipynb ............... [ 48%]
[2023-11-30T16:32:43.085Z] .............                                                            [ 53%]
[2023-11-30T16:32:46.224Z] pavics-sdi-master/docs/source/notebooks/rendering.ipynb ....             [ 54%]
[2023-11-30T16:32:51.268Z] pavics-sdi-master/docs/source/notebooks/subset-user-input.ipynb ........ [ 58%]
[2023-11-30T16:33:11.453Z] .................                                                        [ 64%]
[2023-11-30T16:33:19.808Z] pavics-sdi-master/docs/source/notebooks/subsetting.ipynb ......          [ 67%]
[2023-11-30T16:33:21.727Z] pavics-sdi-master/docs/source/notebook-components/weaver_example.ipynb . [ 67%]
[2023-11-30T16:33:42.290Z] .........                                                                [ 70%]
[2023-11-30T16:33:55.762Z] finch-master/docs/source/notebooks/dap_subset.ipynb ...........          [ 75%]
[2023-11-30T16:34:05.998Z] finch-master/docs/source/notebooks/finch-usage.ipynb ......              [ 77%]
[2023-11-30T16:34:08.545Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-1DataAccess.ipynb . [ 78%]
[2023-11-30T16:34:12.378Z] ......                                                                   [ 80%]
[2023-11-30T16:34:18.962Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-2Subsetting.ipynb . [ 80%]
[2023-11-30T16:34:34.253Z] .............                                                            [ 85%]
[2023-11-30T16:34:44.266Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-3Climate-Indicators.ipynb . [ 86%]
[2023-11-30T16:35:20.837Z] ....s.                                                                   [ 88%]
[2023-11-30T16:35:28.969Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-4Ensembles.ipynb . [ 89%]
[2023-11-30T16:35:42.239Z] ...                                                                      [ 90%]
[2023-11-30T16:35:57.166Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-5Visualization.ipynb . [ 90%]
[2023-11-30T16:36:21.615Z] ......                                                                   [ 92%]
[2023-11-30T16:36:26.289Z] notebooks/hummingbird.ipynb ............                                 [ 97%]
[2023-11-30T16:39:06.701Z] notebooks/stress-tests.ipynb ......                                      [100%]
[2023-11-30T16:39:06.701Z] 
[2023-11-30T16:39:06.701Z] ================= 254 passed, 1 skipped in 1525.26s (0:25:25) ==================
    
  

Copy link
Collaborator

@tlvu tlvu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks, this will be useful.

Copy link
Collaborator

@fmigneault fmigneault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bad idea to instruct users to use env variables for cookies (note: plain text password are not better either). It can give the false impression that this is more secure.

If the cookie is printed in the output or stored anywhere in the notebook, it could leak access.

Another issue is that cookies are not persistent. Once a refresh occurs, the value set in MAGPIE_COOKIES will not be valid anymore. This will confuse the users even more.

I'm not sure what would be the best solution yet, but my first impression is that MAGPIE_COOKIES trades a problem for another.

@tlvu
Copy link
Collaborator

tlvu commented Nov 30, 2023

If the cookie is printed in the output or stored anywhere in the notebook, it could leak access.

I think the cookie is supposed to be temporary. If user does another login, it will invalidate the old cookie.

It's about the same risk as all the secrets that CI pipeline made available to tests. Any rogues tests running on the same CI system can potentially steal/log all those secrets.

Another issue is that cookies are not persistent. Once a refresh occurs, the value set in MAGPIE_COOKIES will not be valid anymore. This will confuse the users even more.

Ah this one I never though of ! Given the tighter integration between JupyterHub session and Magpie (login to JupyterHub or Magpie will also login to the other one automatically) I thought this issue should not arise.

If indeed MAGPIE_COOKIES do not work on refresh, I think we better not deploy it to avoid confusing users.

@fmigneault
Copy link
Collaborator

I don't know if the Jupyter authenticator would be able to dynamically update the value of MAGPIE_COOKIES in the kernel if it detected a refresh value change during its logged-user status check. If it can, then the MAGPIE_COOKIES approach would be safer than plain text passwords.

@mishaschwartz
Copy link
Collaborator Author

Ok so just so I understand correctly, the situation that you're worried about is:

  • a user logs in to jupyterhub and the magpie cookie is added to the environment
  • a user leaves the jupyterlab server running long enough so the cookie expires (default = 24 hours)
  • the user logs back into jupyterhub but the environment variable is not recreated because it is only set when the container is spawned

This is a valid problem which we should consider. It could be mitigated with good documentation but if we can make this transparent to the user that would be better.

I don't know if the Jupyter authenticator would be able to dynamically update the value of MAGPIE_COOKIES in the kernel if it detected a refresh value change during its logged-user status check. If it can, then the MAGPIE_COOKIES approach would be safer than plain text passwords.

It can't, but we can dynamically access it using a different method, let me update this PR with the alternative method and you can let me know what you think.

@mishaschwartz mishaschwartz changed the title Add magpie cookie as environment variable in jupyterlab server Allow user to access their Magpie cookie programmatically Dec 1, 2023
@mishaschwartz
Copy link
Collaborator Author

@fmigneault note that the new method accesses the cookie value stored in the jupyterhub database directly. So this scenario:

  • a user logs in to jupyterhub and the magpie cookie is added to the environment
  • a user leaves the jupyterlab server running long enough so the cookie expires (default = 24 hours)
  • the user logs back into jupyterhub but the environment variable is not recreated because it is only set when the container is spawned

becomes:

  • a user logs in to jupyterhub and the magpie cookie is added to the jupyterhub database
  • a user leaves the jupyterlab server running long enough so the cookie expires (default = 24 hours)
  • the user logs back into jupyterhub and the database value is updated because it is set whenever the user logs in

@crim-jenkins-bot
Copy link
Collaborator

E2E Test Results

DACCS-iac Pipeline Results

Build URL : http://daccs-jenkins.crim.ca:80/job/DACCS-iac-birdhouse/2334/
Result : failure

BIRDHOUSE_DEPLOY_BRANCH : add-magpie-cookie-as-env-var
DACCS_CONFIGS_BRANCH : master
PAVICS_E2E_WORKFLOW_TESTS_BRANCH : master
PAVICS_SDI_BRANCH : master

DESTROY_INFRA_ON_EXIT : true
PAVICS_HOST : https://host-140-154.rdext.crim.ca

PAVICS-e2e-workflow-tests Pipeline Results

Tests URL : http://daccs-jenkins.crim.ca:80/job/PAVICS-e2e-workflow-tests/job/master/1459/

NOTEBOOK TEST RESULTS
    
[2023-12-01T17:02:02.347Z] ============================= test session starts ==============================
[2023-12-01T17:02:02.347Z] platform linux -- Python 3.9.16, pytest-7.3.1, pluggy-1.0.0
[2023-12-01T17:02:02.347Z] rootdir: /home/jenkins/agent/workspace/PAVICS-e2e-workflow-tests_master
[2023-12-01T17:02:02.347Z] plugins: anyio-3.6.1, dash-2.10.0, nbval-0.9.6, tornasync-0.6.0.post2, xdist-3.3.1
[2023-12-01T17:02:02.347Z] collected 265 items
[2023-12-01T17:02:02.347Z] 
[2023-12-01T17:02:18.232Z] notebooks-auth/geoserver.ipynb ..................                        [  6%]
[2023-12-01T17:02:26.849Z] notebooks-auth/test_cowbird_jupyter.ipynb ......FFF.                     [ 10%]
[2023-12-01T17:02:36.197Z] notebooks-auth/test_thredds.ipynb ...........                            [ 14%]
[2023-12-01T17:02:44.786Z] pavics-sdi-master/docs/source/notebooks/WCS_example.ipynb .......        [ 17%]
[2023-12-01T17:02:55.340Z] pavics-sdi-master/docs/source/notebooks/WFS_example.ipynb ......         [ 19%]
[2023-12-01T17:03:05.197Z] pavics-sdi-master/docs/source/notebooks/WMS_example.ipynb ........       [ 22%]
[2023-12-01T17:34:20.809Z] pavics-sdi-master/docs/source/notebooks/climex.ipynb ............        [ 27%]
[2023-12-01T17:34:20.809Z] pavics-sdi-master/docs/source/notebooks/eccc-geoapi-climate-stations.ipynb . [ 27%]
[2023-12-01T17:34:28.182Z] ...............                                                          [ 33%]
[2023-12-01T17:34:38.165Z] pavics-sdi-master/docs/source/notebooks/eccc-geoapi-xclim.ipynb .....    [ 35%]
[2023-12-01T17:34:45.854Z] pavics-sdi-master/docs/source/notebooks/esgf-dap.ipynb ......            [ 37%]
[2023-12-01T17:35:04.303Z] pavics-sdi-master/docs/source/notebooks/forecasts.ipynb ......           [ 39%]
[2023-12-01T17:35:05.947Z] pavics-sdi-master/docs/source/notebooks/jupyter_extensions.ipynb .       [ 40%]
[2023-12-01T17:35:11.738Z] pavics-sdi-master/docs/source/notebooks/opendap.ipynb .......            [ 42%]
[2023-12-01T17:35:16.511Z] pavics-sdi-master/docs/source/notebooks/pavics_thredds.ipynb .....       [ 44%]
[2023-12-01T17:39:52.394Z] pavics-sdi-master/docs/source/notebooks/regridding.ipynb ............... [ 50%]
[2023-12-01T17:41:12.501Z] .............                                                            [ 55%]
[2023-12-01T17:41:16.858Z] pavics-sdi-master/docs/source/notebooks/rendering.ipynb ....             [ 56%]
[2023-12-01T17:41:19.187Z] pavics-sdi-master/docs/source/notebooks/subset-user-input.ipynb ........ [ 59%]
[2023-12-01T17:41:36.596Z] .................                                                        [ 66%]
[2023-12-01T17:41:44.932Z] pavics-sdi-master/docs/source/notebooks/subsetting.ipynb ......          [ 68%]
[2023-12-01T17:41:46.846Z] pavics-sdi-master/docs/source/notebook-components/weaver_example.ipynb . [ 68%]
[2023-12-01T17:41:49.138Z] .FFFFFFFF                                                                [ 72%]
[2023-12-01T17:41:59.218Z] finch-master/docs/source/notebooks/dap_subset.ipynb ...........          [ 76%]
[2023-12-01T17:42:09.226Z] finch-master/docs/source/notebooks/finch-usage.ipynb ......              [ 78%]
[2023-12-01T17:42:10.616Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-1DataAccess.ipynb . [ 78%]
[2023-12-01T17:42:13.913Z] ......                                                                   [ 81%]
[2023-12-01T17:42:22.048Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-2Subsetting.ipynb . [ 81%]
[2023-12-01T17:42:36.683Z] .............                                                            [ 86%]
[2023-12-01T17:42:48.906Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-3Climate-Indicators.ipynb . [ 86%]
[2023-12-01T17:43:31.035Z] ....s.                                                                   [ 89%]
[2023-12-01T17:43:39.158Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-4Ensembles.ipynb . [ 89%]
[2023-12-01T17:43:53.937Z] ...                                                                      [ 90%]
[2023-12-01T17:44:08.843Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-5Visualization.ipynb . [ 90%]
[2023-12-01T17:44:34.360Z] ......                                                                   [ 93%]
[2023-12-01T17:44:37.640Z] notebooks/hummingbird.ipynb ............                                 [ 97%]
[2023-12-01T17:47:17.226Z] notebooks/stress-tests.ipynb ......                                      [100%]
[2023-12-01T17:47:17.226Z] 
[2023-12-01T17:47:17.226Z] =================================== FAILURES ===================================
    
  

@crim-jenkins-bot
Copy link
Collaborator

E2E Test Results

DACCS-iac Pipeline Results

Build URL : http://daccs-jenkins.crim.ca:80/job/DACCS-iac-birdhouse/2335/
Result : failure

BIRDHOUSE_DEPLOY_BRANCH : add-magpie-cookie-as-env-var
DACCS_CONFIGS_BRANCH : master
PAVICS_E2E_WORKFLOW_TESTS_BRANCH : master
PAVICS_SDI_BRANCH : master

DESTROY_INFRA_ON_EXIT : true
PAVICS_HOST : https://host-140-46.rdext.crim.ca

PAVICS-e2e-workflow-tests Pipeline Results

Tests URL : http://daccs-jenkins.crim.ca:80/job/PAVICS-e2e-workflow-tests/job/master/1460/

NOTEBOOK TEST RESULTS
    
[2023-12-01T17:05:30.502Z] ============================= test session starts ==============================
[2023-12-01T17:05:30.502Z] platform linux -- Python 3.9.16, pytest-7.3.1, pluggy-1.0.0
[2023-12-01T17:05:30.502Z] rootdir: /home/jenkins/agent/workspace/PAVICS-e2e-workflow-tests_master@2
[2023-12-01T17:05:30.502Z] plugins: anyio-3.6.1, dash-2.10.0, nbval-0.9.6, tornasync-0.6.0.post2, xdist-3.3.1
[2023-12-01T17:05:30.502Z] collected 265 items
[2023-12-01T17:05:30.502Z] 
[2023-12-01T17:05:39.784Z] notebooks-auth/geoserver.ipynb ..................                        [  6%]
[2023-12-01T17:05:50.334Z] notebooks-auth/test_cowbird_jupyter.ipynb ......FFF.                     [ 10%]
[2023-12-01T17:05:58.341Z] notebooks-auth/test_thredds.ipynb ...........                            [ 14%]
[2023-12-01T17:06:07.311Z] pavics-sdi-master/docs/source/notebooks/WCS_example.ipynb .......        [ 17%]
[2023-12-01T17:06:45.292Z] pavics-sdi-master/docs/source/notebooks/WFS_example.ipynb ......         [ 19%]
[2023-12-01T17:06:52.575Z] pavics-sdi-master/docs/source/notebooks/WMS_example.ipynb ........       [ 22%]
[2023-12-01T17:35:02.086Z] pavics-sdi-master/docs/source/notebooks/climex.ipynb ............        [ 27%]
[2023-12-01T17:35:04.626Z] pavics-sdi-master/docs/source/notebooks/eccc-geoapi-climate-stations.ipynb . [ 27%]
[2023-12-01T17:35:13.203Z] ...............                                                          [ 33%]
[2023-12-01T17:35:23.500Z] pavics-sdi-master/docs/source/notebooks/eccc-geoapi-xclim.ipynb .....    [ 35%]
[2023-12-01T17:35:31.379Z] pavics-sdi-master/docs/source/notebooks/esgf-dap.ipynb ......            [ 37%]
[2023-12-01T17:35:48.507Z] pavics-sdi-master/docs/source/notebooks/forecasts.ipynb ......           [ 39%]
[2023-12-01T17:35:50.432Z] pavics-sdi-master/docs/source/notebooks/jupyter_extensions.ipynb .       [ 40%]
[2023-12-01T17:35:55.287Z] pavics-sdi-master/docs/source/notebooks/opendap.ipynb .......            [ 42%]
[2023-12-01T17:36:00.184Z] pavics-sdi-master/docs/source/notebooks/pavics_thredds.ipynb .....       [ 44%]
[2023-12-01T17:39:59.555Z] pavics-sdi-master/docs/source/notebooks/regridding.ipynb ............... [ 50%]
[2023-12-01T17:41:11.680Z] .............                                                            [ 55%]
[2023-12-01T17:41:14.428Z] pavics-sdi-master/docs/source/notebooks/rendering.ipynb ....             [ 56%]
[2023-12-01T17:41:16.635Z] pavics-sdi-master/docs/source/notebooks/subset-user-input.ipynb ........ [ 59%]
[2023-12-01T17:41:34.079Z] .................                                                        [ 66%]
[2023-12-01T17:41:42.421Z] pavics-sdi-master/docs/source/notebooks/subsetting.ipynb ......          [ 68%]
[2023-12-01T17:41:43.800Z] pavics-sdi-master/docs/source/notebook-components/weaver_example.ipynb . [ 68%]
[2023-12-01T17:42:02.078Z] .........                                                                [ 72%]
[2023-12-01T17:42:11.558Z] finch-master/docs/source/notebooks/dap_subset.ipynb ...........          [ 76%]
[2023-12-01T17:42:20.902Z] finch-master/docs/source/notebooks/finch-usage.ipynb ......              [ 78%]
[2023-12-01T17:42:22.293Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-1DataAccess.ipynb . [ 78%]
[2023-12-01T17:42:25.366Z] ......                                                                   [ 81%]
[2023-12-01T17:42:33.506Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-2Subsetting.ipynb . [ 81%]
[2023-12-01T17:42:48.785Z] .............                                                            [ 86%]
[2023-12-01T17:42:58.797Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-3Climate-Indicators.ipynb . [ 86%]
[2023-12-01T17:43:41.472Z] ....s.                                                                   [ 89%]
[2023-12-01T17:43:49.622Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-4Ensembles.ipynb . [ 89%]
[2023-12-01T17:44:06.080Z] ...                                                                      [ 90%]
[2023-12-01T17:44:21.005Z] PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-5Visualization.ipynb . [ 90%]
[2023-12-01T17:44:46.292Z] ......                                                                   [ 93%]
[2023-12-01T17:44:49.055Z] notebooks/hummingbird.ipynb ............                                 [ 97%]
[2023-12-01T17:47:23.201Z] notebooks/stress-tests.ipynb ......                                      [100%]
[2023-12-01T17:47:23.201Z] 
[2023-12-01T17:47:23.201Z] =================================== FAILURES ===================================
    
  

Copy link
Collaborator

@tlvu tlvu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -24,6 +24,26 @@ if os.getenv("JUPYTERHUB_CRYPT_KEY"):
c.MagpieAuthenticator.refresh_pre_spawn = True
c.MagpieAuthenticator.auth_refresh_age = int("${JUPYTERHUB_AUTHENTICATOR_REFRESH_AGE}")

# Allow users to access their own auth_state in order to get their own magpie cookie
# See https://github.com/jupyterhub/jupyterhub/issues/3588 for details
c.JupyterHub.load_roles = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume JUPYTER_API_TOKEN now exists because of this new config?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I think it always existed in the environment

@tlvu
Copy link
Collaborator

tlvu commented Dec 1, 2023

  • the user logs back into jupyterhub and the database value is updated because it is set whenever the user logs in

Curious, when the user logs back into Jupyterhub, isn't the MAGPIE_COOKIES updated as well?

@mishaschwartz
Copy link
Collaborator Author

Curious, when the user logs back into Jupyterhub, isn't the MAGPIE_COOKIES updated as well?

No the problem is that the environment variables are only set once when the jupyterlab server first spawns

Copy link
Collaborator

@fmigneault fmigneault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the new JupyterHub API alternative is a good solution.

Please make it slightly more explicit in the CHANGES which code (first) is to avoid and the new "STRONGLY RECOMMENDED" approach to use instead.

That should also be described somewhere else in docs because it will get lost over time with future releases.

@mishaschwartz
Copy link
Collaborator Author

That should also be described somewhere else in docs because it will get lost over time with future releases.

I'll make sure we document it in the jupyterhub tutorials (in progress: DACCS-Climate/marble-tutorials#18)

@github-actions github-actions bot added the ci/operations Continuous Integration components label Dec 7, 2023
@mishaschwartz mishaschwartz merged commit f075263 into master Dec 7, 2023
4 of 5 checks passed
@mishaschwartz mishaschwartz deleted the add-magpie-cookie-as-env-var branch December 7, 2023 15:37
@crim-jenkins-bot
Copy link
Collaborator

E2E Test Results

DACCS-iac Pipeline Results

Build URL : http://daccs-jenkins.crim.ca:80/job/DACCS-iac-birdhouse/2346/
Result : failure

BIRDHOUSE_DEPLOY_BRANCH : add-magpie-cookie-as-env-var
DACCS_CONFIGS_BRANCH : master
PAVICS_E2E_WORKFLOW_TESTS_BRANCH : master
PAVICS_SDI_BRANCH : master

DESTROY_INFRA_ON_EXIT : true
PAVICS_HOST : https://host-140-154.rdext.crim.ca

Infrastructure deployment failed. Instance has not been destroyed. @matprov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/operations Continuous Integration components component/jupyterhub Related to JupyterHub as development frontend with notebooks documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants