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

[GitHub] Set JH user's email with non-public email if needed and granted scope to do so #442

Merged
merged 8 commits into from
Jul 18, 2021

Conversation

satra
Copy link
Contributor

@satra satra commented Jun 5, 2021

This allows emails to be read and set in the state dictionary when scope is authorized.

closes jupyterhub#438
@welcome
Copy link

welcome bot commented Jun 5, 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! 🎉

oauthenticator/github.py Outdated Show resolved Hide resolved
Copy link
Member

@consideRatio consideRatio left a comment

Choose a reason for hiding this comment

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

Thank you @satra for working on this! ❤️ 🎉

Overall I think this make sense! There are some technical details I'd hope to get implemented in a robust way directly in this PR as I believe this PR is going to lead the way for additional PRs and become a pattern to make further use of the /user endpoint that returns more details about the user.

Suggested changes

  • Include user alongisde user:email in the check to decide if collecting additional information from the user endpoint is relevant.
  • I'd like the comment on line 194-195 to reflect the difference between the single public email, and the plural private emails
  • I'd like to know this is at least manually tested against a user with multiple private emails registered, and that we understand the return value in those circumstances. Based on the code it seems like we get a primary email, then I think the action point I ask for is to clarify that while user:email provides info about all emails, we only use the primary email.
  • Update PR description to include mentioning of https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps#available-scopes as a reference about this

Open questions

self.scope is checked, but I think this is what the user has requested, not what was granted. Is there a point where we update self.scope (the server's spawner object's scope field) or where we keep track of the granted scopes vs the requested scopes?

There is no point for us to make a request if the granted scope lacks permissions, so can we acquire the granted scopes from the response when we get the token to call the /user endpoint perhaps?

https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps#requested-scopes-and-granted-scopes

@satra
Copy link
Contributor Author

satra commented Jun 5, 2021

@consideRatio - changing the logic to first check if public email is set, and relying on HTTP error rather than scope to set the email. i could not figure out a way to determine what scopes were granted, and it seemed simpler to rely on the endpoint.

@satra
Copy link
Contributor Author

satra commented Jun 5, 2021

nevermind, found how to get scopes. so the current state should cover your comments.

Co-authored-by: Erik Sundell <erik.i.sundell@gmail.com>
Co-authored-by: Erik Sundell <erik.i.sundell@gmail.com>
@consideRatio consideRatio changed the title fix: allow emails to be read but github authenticator [GitHub] Set JH user's email with non-public email if needed and granted scope to do so Jul 18, 2021
Copy link
Member

@consideRatio consideRatio left a comment

Choose a reason for hiding this comment

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

This looks great! Thanks for your thorough work @satra! This will be included in 14.1.0 release coming this week I hope.

@consideRatio consideRatio merged commit efe9c4c into jupyterhub:master Jul 18, 2021
@welcome
Copy link

welcome bot commented Jul 18, 2021

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GitHub OAuth process not retrieving email address.
2 participants