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

[Generic] Implement refresh_user to periodically refresh OAuth tokens #475

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jthiltges
Copy link

An attempt at OAuth token refresh, following the pattern in PR #287, without relying on tokens to be JWTs. This should address at least some of issue #398.

Requirements for token refresh:

  • OAuth server response includes expires_in and refresh_token
  • State is persisted on hub with c.Authenticator.enable_auth_state = True (to store the refresh_token)

Requirements for token refresh:

- OAuth server response includes `expires_in` and `refresh_token`
- State is persisted on hub with `c.Authenticator.enable_auth_state = True`
@welcome
Copy link

welcome bot commented Dec 28, 2021

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@kkaraivanov1
Copy link

As in the next release of jupyterhub there will be authenticator user group management jupyterhub/jupyterhub#3548 what happens if we have manage_groups=true and the user's group membership changes after auth and before refresh? Your refresh code is not updating user_info['groups'] as it seem.

@jthiltges
Copy link
Author

@kkaraivanov1 Thanks for looking at the PR. I agree that group data should be refreshed as well.

Is group membership info already being stored on authentication?

@kkaraivanov1
Copy link

The way I understand the intentions behind the PR I mention is if c.Authenticator.manage_groups is set AND if the GenericOAuthenticator adds the groups to user_info['groups'] they will be populated automatically.
So to answer your question - it could be
Perhaps you can hide that behind a check like if hasattr(self,manage_groups): ........ Please take my thoughts with big grain of salt, I'm not a dev and my python is rudimentary.

@jthiltges
Copy link
Author

That makes sense, and thank you for the clarification.

Adding support for user_info['groups'] is probably best addressed in a separate PR. I'll be happy to revise this PR to follow the pattern that the project maintainers prefer.

grant_type='refresh_token',
)

headers = self._get_headers()

Choose a reason for hiding this comment

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

this one is wrong. It has to be
headers = { "Content-Type": "application/x-www-form-urlencoded" }

…expiration

Follows the convention of Let's Encrypt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants