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] Authorization by GitHub repository access #650

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

Conversation

koendelaat
Copy link

Allows for GitHub authentication based on repository access, which is required when using outside-collaborators.

Current situation only allows authorization based on org or org/team access. This requires all users to be a member of this org.

With outside-collaborators, we can grant them access to specific repositories, but they don't become member of the organization nor the teams.

This feature allow authorization based on repository access, making JupyterHub accessible to outside-collaborators.

Allows for authentication based on repository access, which is required when using outside-collaborators.
@welcome
Copy link

welcome bot commented Jul 7, 2023

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! 🎉

@koendelaat koendelaat changed the title Authorization by GitHub repository access [GitHub] Authorization by GitHub repository access Jul 7, 2023
@koendelaat
Copy link
Author

@consideRatio any comments?

oauthenticator/github.py Outdated Show resolved Hide resolved
"user" in granted_scopes or "user:email" in granted_scopes
"user" in granted_scopes
or "user:email" in granted_scopes
or not granted_scopes
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain this change? If this is called with empty scopes won't it fail to get the user's emails?

Copy link
Author

Choose a reason for hiding this comment

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

The retrieved scopes will be empty for GitHub Apps https://docs.github.com/en/developers/apps.
So to facilitate this behavior, empty scopes are also allowed.
This is also why we need a change in error handling of the email fetch. This might cause an error, but we don't know upfront what is causing this.

allowed_repositories = Set(
config=True,
help="""
Allow users with read access to specified repositories by specifying
Copy link
Member

Choose a reason for hiding this comment

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

We also need to think about future maintainability. Could you say a bit about your design decisions to make this conditional on read access as opposed to e.g. write access, making it configurable etc?

Copy link
Author

@koendelaat koendelaat Jul 17, 2023

Choose a reason for hiding this comment

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

Good point. I thought about it and had the following observations:

  • The used app can be either a GitHub OAuth app, or a 'normal' GitHub App
    • When using a OAuth app, repo access is completely depending on the users permissions
    • When using a GitHub App, repo access is an intersection of the apps permissions and the users permissions
  • Read access to a repo is the minimal, and is also relatively easy to verify.
  • Write access is harder to verify

Our use-case is an internal (private) repo with example code. We would like to co-create with outside collaborators and for that we give them read-access to this example repository. Also we would give them a JupyterHub environment where they can use these examples. That is why this change is proposed.

@koendelaat
Copy link
Author

@manics Any comments on my replies?

@koendelaat
Copy link
Author

@manics, @consideRatio Can you maybe have a look to this PR?

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.

I'm positive to this idea in general!

I'm super low on time december, but quick input:

  • make who to allow in a repo explicit (only maintainers and up, only triagers and up, etc)
    who to allow isnt obvious based on triager/maintainer etc status. I think the config should specify that (repo x + permission y) should have access, and not just repo x and assume a specific permission level is enough for all repos configured.

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.

3 participants