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

Add flag to only access public repositories on GitHub #3566

Merged
merged 3 commits into from
Mar 29, 2024

Conversation

aumetra
Copy link
Contributor

@aumetra aumetra commented Mar 28, 2024

This PR adds the WOODPECKER_GITHUB_ONLY_PUBLIC which instructs the GitHub client to only obtain clients which have permissions to operate on public repositories.

We have tested these changes on our own instance and can report that at least the basic functionality works.
Someone please feel free to chime in if this breaks any other functionality of Woodpecker we weren't aware of.

Rationale: This follows the principle of least privilege. We run a public Woodpecker instance for an open-source project. We never intend to run it on anything but public repositories.
The standard permissions are rather scary though.

Read and write access to all public and private data including settings, deploy keys, code, collaboration invites, etc.

By restricting access to the following scopes:

  • admin:repo_hook
  • repo:status
  • user:email
  • read:org

we can still have all the functionality Woodpecker needs (manage webhooks, update repository statuses, etc.) without the scary settings such as invites, writing to all aspects, etc.


New authorization dialog:

image

@qwerty287 qwerty287 added forge/github github forge related enhancement improve existing features labels Mar 29, 2024
@qwerty287 qwerty287 added this to the 2.5.0 milestone Mar 29, 2024
cmd/server/flags.go Outdated Show resolved Hide resolved
cmd/server/flags.go Outdated Show resolved Hide resolved
@aumetra
Copy link
Contributor Author

aumetra commented Mar 29, 2024

By the way, does Woodpecker need only write access to webhooks? Or does it need to delete them, too?
Because if it only needs to write and read, then we could further restrict the scopes, away from admin:repo_hook to write:repo_hook

@qwerty287
Copy link
Contributor

No, woodpecker deletes them when you disable a repo, so this scope is necessary.

Copy link
Contributor

@qwerty287 qwerty287 left a comment

Choose a reason for hiding this comment

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

Can you update your branch or allow updates from maintainers?

@aumetra
Copy link
Contributor Author

aumetra commented Mar 29, 2024

Branch is up-to-date (I think allowing changes just isn't a thing I can do because the fork is owned by an org)

@woodpecker-bot
Copy link
Collaborator

woodpecker-bot commented Mar 29, 2024

Deployment of preview was successful: https://woodpecker-ci-woodpecker-pr-3566.surge.sh

@aumetra
Copy link
Contributor Author

aumetra commented Mar 29, 2024

The ci/woodpecker/pr/static fail seems like a temporary fail due to network issues.

@qwerty287 qwerty287 merged commit 20b84a1 into woodpecker-ci:main Mar 29, 2024
6 of 7 checks passed
@aumetra aumetra deleted the only-public-flag branch March 29, 2024 13:48
@woodpecker-bot woodpecker-bot mentioned this pull request Apr 1, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improve existing features forge/github github forge related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants