Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Add the logic to refresh user auth info #6

Merged
merged 1 commit into from
Jun 2, 2021

Conversation

vpavlin
Copy link

@vpavlin vpavlin commented May 26, 2021

No description provided.

@crobby
Copy link

crobby commented Jun 1, 2021

Does this contain many of the same changes as #5? Assuming this will need to be rebased after #5 merges.

@vpavlin
Copy link
Author

vpavlin commented Jun 2, 2021

I mentioned it somewhere, but for whatever reason forgot to put it in description - sorry:(

Yes, this contains the rebase, hence I also submited that one separatly. Only the last commit will be part of this PR once the rebase is merged

@vpavlin
Copy link
Author

vpavlin commented Jun 2, 2021

@crobby Rebased

Copy link

@crobby crobby left a comment

Choose a reason for hiding this comment

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

lgtm, demo was good.

@LaVLaS
Copy link

LaVLaS commented Jun 2, 2021

I was able to build and image test with the oauthenticator library. The initial login tests worked:

  • No authorized groups w/ two separate users
  • Authorized groups with only one user authorized and other denied correctly

Removing the JH user group appears to have left the UI in a blank state and any attempts to login/logout will no allow someone to actually login as the same or a different user

image

await user.stop()

return user_info

Copy link

Choose a reason for hiding this comment

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

@vpavlin who calls refresh_user? seems like this function returns user_info even when None?

Copy link
Author

Choose a reason for hiding this comment

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

JupyterHub itself calls it regularly based on auth_refresh_age configuration...default is 300s.

It also gets called before spawning new server when refresh_pre_spawn=True which is desired for us

It returns 3 states True (user info is still valid), False (user info is invalid and needs re-authentication), dict (user info needs to be updated with given values).

So when we return None it means user needs to go through auth again.

ocp_user = await self.fetch(req) #TODO: tornado.httpclient.HTTPClientError: HTTP 401: Unauthorized
except HTTPError as ex:
if ex.code == 401:
return None
Copy link

Choose a reason for hiding this comment

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

Is 401 the only HTTP we need to handle, what about 403: Forbidden?

Copy link
Author

Choose a reason for hiding this comment

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

This call is to get user's own data from OpenShift OAuth API, so it cannot return Forbidden - it can only return the data or 401...or potentially any other error, but that results in exception which is expected

@LaVLaS
Copy link

LaVLaS commented Jun 2, 2021

Since the blank UI issue was not introduced by this change, I have not objections to merging.

Resolving the logout/login issue I encountered will require the changes in opendatahub-io-contrib/jupyterhub-odh#95

@crobby crobby merged commit d98936d into opendatahub-io-contrib:master Jun 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants