-
Notifications
You must be signed in to change notification settings - Fork 88
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
use NB_USER rather than getpass.getuser() #132
Conversation
Is this extension designed to only work with jupyter/docker-stacks images where |
@manics It should work in the more general case. So either the authenticator needs to pass in something useful in @vivian-rook's deployment, or the username needs to be configurable here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
jupyter_rsession_proxy/__init__.py
Outdated
@@ -45,7 +45,7 @@ def rewrite_auth(response, request): | |||
|
|||
def setup_rserver(): | |||
def _get_env(port): | |||
return dict(USER=getpass.getuser()) | |||
return dict(USER=os.environ.get('NB_USER')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should go through the following hierarchy:
- If
JUPYTER_USER
is set, use that. That's the logged-in username, if using a JupyterHub - If
NB_USER
is set, use that. This defaults tojovyan
I think? - Use
getpass.getuser()
if neither of these are set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is JUPYTER_USER
guaranteed to exist as a system user? I only see JUPYTERHUB_USER
in PAWS, and that is not a system user in the container.
The args to --server-user
and --user-identity
need to be a system user, as I understand it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the rsession-proxy use the above order, but have additional logic to verify that it is also a system user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I meant JUPYTERHUB_USER
not JUPYTER_USER
.
@vivian-rook I don't think it matters for rsession-proxy that it is a system user. Is that right, @ryanlovett?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yuvipanda I think the problem with #129 is that Chicocvenancio
not a system user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah goddamit, apparently i left my reading comprehension skills at home. Sorry!
In that case, can we try:
pwd.getpwuid(os.getuid())[0]
, which should return a username that's in thepwd
database.- If this fails, then use
NB_USER
.
How does that sound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. @ryanlovett looks ok to you?
Thanks a lot, @vivian-rook!
@yuvipanda The only suggestion I have is to have a fallback in the call to retrieve NB_USER, e.g. |
@vivian-rook if you can test this and it works, am happy to merge. |
@yuvipanda, @vivian-rook works for me with local jupyterhub. |
@yuvipanda Works for me off the latest build in toolforge/paws#173 |
Thanks a lot, @vivian-rook @chicocvenancio and @ryanlovett! |
Sorry for the open/close PRs this gets us unblocked in a way that doesn't use my repository.
Resolves #129