Ouranosinc / Magpie

AuthN/AuthZ services
https://pavics-magpie.readthedocs.io
Apache License 2.0
1 stars 5 forks source link

[BUG] [PAVICS] Logging in via email/password does not provide account name #598

Closed Zeitsperre closed 8 months ago

Zeitsperre commented 8 months ago

Describe the bug

This just happened with a user today.

The user forgot his username and decided to use his email to log in to PAVICS (via JupyterLab). They were authenticated by Magpie, and proceeded to enter their workspace, but the docker image failed to build. Upon inspection, the URL shows that instead of the account name (e.g. jupyter/user/myusername), PAVICS attempted to spawn an instance using their email (e.g. jupyter/user/me@mydomain.ca).

To Reproduce

  1. Logout of instances of Magpie/PAVICS-JupyterLab
  2. Login to PAVICS-JupyterLab using email associated with account and password
  3. Attempt to spin up a docker image of a PAVICS-JupyterLab workspace

Expected behavior If an email is used to log in, the workspace URL should use the associated account name and not the email. It should also not hang for several minutes, then crash.

Screenshots

thumbnail_image002

Desktop (please complete the following information):

github-actions[bot] commented 8 months ago

Thanks for submitting an issue. Make sure you have checked for similar issues. Also, provide enough details for us to be able to replicate the problem.

tlvu commented 8 months ago

@fmigneault is there a config switch in Magpie to disable login using email?

mishaschwartz commented 8 months ago

This is because jupyterhub uses the value that is provided by the user in the "Username" field to determine the jupyter_hub user name:

https://github.com/Ouranosinc/jupyterhub/blob/4.0.2-20231130/jupyterhub_magpie_authenticator/jupyterhub_magpie_authenticator.py#L88

It is a quirk of Magpie that you can provide an email address in the "user_name" field and it will work with the exact same behaviour.

Note that this has been the case since the introduction of the Magpie Jupyterhub Authenticator:

https://github.com/Ouranosinc/jupyterhub/blob/1.0.0-20200130/jupyterhub_magpie_authenticator/jupyterhub_magpie_authenticator.py#L33

fmigneault commented 8 months ago

I believe the issue here is more on the JupyterHub login handler than Magpie. It should do a request /magpie/users/current with the obtained login token to retrieve the user name instead of assuming it is the provided value.

Zeitsperre commented 8 months ago

If this issue should be moved to the JupyterLab repo, feel free to transfer it. This really threw me and the user who was having trouble for a loop this morning.

mishaschwartz commented 8 months ago

I believe the issue here is more on the JupyterHub login handler than Magpie. It should do a request /magpie/users/current with the obtained login token to retrieve the user name instead of assuming it is the provided value.

Alright, I can work on that

mishaschwartz commented 8 months ago

@fmigneault

fix in place here: https://github.com/Ouranosinc/jupyterhub/pull/26

(sorry I can't add you as a reviewer)

tlvu commented 8 months ago

@fmigneault

fix in place here: Ouranosinc/jupyterhub#26

(sorry I can't add you as a reviewer)

fmigneault added as reviewer.