-
Notifications
You must be signed in to change notification settings - Fork 7
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
🐛 [BUG]: magpie allows special characters in usernames that mess up jupyterhub #393
Comments
Dupe of Ouranosinc/Magpie#497. I have had this problem before so the current work-around is to manually remember to only use alphanumeric char in a username. Being able to supply a username validation regex to Magpie would enforce this. |
Cool! Thanks I must have missed that one.
This is a good idea. I can work on this unless someone at CRIM has the capacity right now? |
I'm going to suggest we don't close this (even though its a duplicate of the Magpie issue) since the solution will end up being a change to Magpie as well as a configuration change to the ini files in this repository as well. |
I think the safest approach would be to use the |
Can you please clarify what you mean. Where are we using user_id instead of user_name (which component)? |
I think @fmigneault means using the user_id in the container name ( For me this is very user unfriendly and error prone. Often we have to chase down which user is using too much resources and currently it's very easy, the user name is directly in the container name. Also we have to keep an eye on the disk space usage for each user so again having the user name directly in the folder path make this much easier, since we have a lot of users. When deleting the user, it's also easy to find and wipe the corresponding persisted data on disk since the user name is in the path name to wipe. With user id, there is a risk we could wipe the wrong data on disk. |
Thanks @tlvu that makes sense. I've added a proposed change to Magpie here (Ouranosinc/Magpie#592) that should allow us to optionally restrict the user names. If that looks good and gets pulled in, I can make a PR here to update the |
I got an idea regarding that. Would it be possible to have system link in the form This way, a custom renaming/regex logic could be applied to obtain redirects for convenience, but real references would use the generic user IDs? You would have a extra step to check those links to figure out the mapping, but it would still be available somewhere. The issue I forsee with custom regexes such as in Ouranosinc/Magpie#592 is that the similar logic will have to be replicated everywhere that needs to resolve the directories. This means, all Weaver WPS output hooks, all Cowbird handlers, and so on. I think it would be wiser to abstract away that logic using integers. I think Ouranosinc/Magpie#592 can still be valid on its own. As an admin, you could ask to restrict certain user names, or even enforce some name conventions. However, I am not in favor of using this as a side-effect that assumes it would resolve all issues elsewhere. It feels more like a hack than a solution. |
I'm not sure I understand this. Right now, weaver WPS output hooks, cowbird handlers, etc. all use the username that is defined in Magpie to create directories. All we're doing is restricting the naming convention for those usernames. I don't understand how this affects weaver or cowbird. |
I guess you're right. I was overthinking it. Usernames would be correct from upstream validation in Magpie. |
This means at deletion time, we will still need to match the Also the
I understand that the new optional validation regex only take effect for new user creation. I won't affect any existing users. So what "manual retrofit" are you referring to? Do you mean a DB migration of existing users? That should not happen because we will be changing their login-id and they won't be able to login anymore to Jupyter. In fact, if they are already able to login to Jupyter, that means their naming convention is already matching the good one. Going forward we are simply able to properly enforce this naming convention. |
Exactly. |
The change was made to the I don't think there will be any old users with invalid names to migrate. If there were old users with usernames that broke jupyterhub you would know already because they would be complaining that they can't use jupyterhub. |
For legacy reasons, we have Magpie users before the time of Jupyter so these users do not use Jupyter so no warranty that their usernames conform to the naming convention. Is there a way to make this additional regex check apply only for new user creation but not when updating existing user (ex: reset their password because too long ago they forgot it or updating their email). Like the admin password 12 char length enforcement, it only trigger if we actually set a new password. If we set again but to the same existing password, the enforcement is bypassed. Else can you document the DB migration steps we can run manually only for a very small list of problematic users? |
It is the same function that performs the check in both cases. However, unless the user name is updated, the email/password should be checked on their own without revalidation of the user name. |
Super, so no need to DB migrate the existing users with "bad" username format. Users sometime forget their password so we simply set a new one. We never had to change a username before. |
@fmigneault Thanks for merging in Ouranosinc/Magpie#592 Unfortunately, while testing the magpie/jupyterhub interface further it looks like the fact that jupyterhub also converts all uppercase characters to lowercase is a problem. Magpie currently only does case insensitive regex comparisons so there's no way to restrict usernames to lowercase only. In order to allow us to enforce this, I've added another PR to Magpie here (Ouranosinc/Magpie#594). |
## Overview When Jupyterhub spawns a new jupyterlab container, it escapes any non-ascii, non-digit character in the username. This results in a username that may not match the expected username (as defined by Magpie). This mismatch results in the container failing to spawn since expected volumes cannot be mounter to the jupyterlab container. This fixes the issue by ensuring that juptyerhub does not convert the username that is receives from Magpie. ## Changes **Non-breaking changes** - limits usernames in Magpie **Breaking changes** - If any users currently exist with invalid usernames, an admin needs to update their user name in Magpie ## Related Issue / Discussion - Resolves #393 ## Additional Information <!-- The test suite can be run using a different DACCS config with ``birdhouse_daccs_configs_branch: branch_name`` in the PR description. To globally skip the test suite regardless of the commit message use ``birdhouse_skip_ci: true`` in the PR description. --> birdhouse_daccs_configs_branch: master birdhouse_skip_ci: false
Summary
Jupyterhub creates jupyterlab docker containers named
jupyter-{username}
where{username}
is the user name of the logged in user.Magpie permits usernames with
.
in them but jupyterhub will substitute the.
with-2e
when creating the jupyterlab container. This means that a user with the nameexample.user
will have a container namedjupyter-example-2euser
and the username according to jupyterlab will beexample-2euser
.This causes problems since we assume that these names will align.
Details
^[A-Za-z0-9]+(?:[\s_\-\.][A-Za-z0-9]+)*$
.
in container names)When spawning a new jupyterlab container, it fails with the following traceback:
I'm not entirely sure why the issue is a permission denied error but the cause is obviously due to an unexpected mismatch between the expected username and the username according to the container.
One possible solution would be to further restrict the valid usernames in magpie, either permanently or only when jupyterhub is enabled.
To Reproduce
.
in their name in magpie (eg:user.name
)docker logs -f jupyter-user.name
Environment
Concerned Organizations
The text was updated successfully, but these errors were encountered: