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

Allow configuration of pipeline permissions #15

Open
jamestelfer opened this issue Apr 29, 2024 · 4 comments
Open

Allow configuration of pipeline permissions #15

jamestelfer opened this issue Apr 29, 2024 · 4 comments

Comments

@jamestelfer
Copy link
Collaborator

jamestelfer commented Apr 29, 2024

Tokens issued by the service become more useful when they can be used for GitHub API requests outside Git operations.

Incorporate a simple YAML configuration file that

  • Defines the default permissions to give to a pipeline (default none)
  • Allows for an allow list of pipelines to vend tokens for
  • A pipeline may have specific permissions granted to it
  • a pipeline definition MAY specify the repository it must be linked to

Bear in mind that periodic retrieval and online reloads will be expected to occur in the future.

The file should be retrieved from the default branch of a configured Git repository.

Out of scope for now:

  • multiple repositories per pipeline (for now)
  • Periodic retrieval
@jamestelfer jamestelfer added this to the v1 release milestone May 11, 2024
@jamestelfer jamestelfer changed the title Pipeline allow list, default permissions and additional permissions Add configuration for a pipeline allow list that includes default permissions and additional permissions Jun 3, 2024
@dstrates
Copy link

dstrates commented Jun 3, 2024

@jamestelfer some initial thoughts on this:

  • the config file may be in a centralised repo?
  • the config file may be in each repo associated with a pipeline?
  • both of the above options (i.e. global config and local config)
    • if both: should local config override global config?

@jamestelfer jamestelfer changed the title Add configuration for a pipeline allow list that includes default permissions and additional permissions Allow configuration of pipeline permissions Jun 4, 2024
@jamestelfer
Copy link
Collaborator Author

To lay out my thinking more completely:

  1. The configuration file can be YAML, stored in a single centralized repository location
  2. Configuration will only be read from the default branch of that repo
  3. The repository name and path will be configurable.
  4. Configuration is by an environment variable, read using the internal/config package. The name would be something like REPOSITORY_CONFIGURATION_URN="github:org/repo/path.yaml", using a URL format that is easily parsed by the url package.
  5. File format will have something like (spitballing here)
default:
  permissions: # empty list, no permissions granted
    - "content:read"
  repositories:
    - name: "org/privaterepo" # optional list of repositories to give access by default
       permissions: ["content:read"] # optional, defaults to permissions above
    - name: "org/otherrepo"

pipelines:
  - name: "pipeline name"
    repositories:
      # potentially implicit here is content:read for the repo of the pipeline
      - name: "org/repo1" # overlap here with defaults results in a union of the available properties
        permissions: ["content:read", "pull-request:write"]
      - name: "org/repo2"
        permissions: ["content:read", "pull-request:write"]

I'm not devoted to this format. Octo STS has a format that is based on the JWT claims instead of the explicit Buildkite theming here. This also allows different permissions for different repositories, something that GitHub doesn't do: its model is the intersection of a set of repos and permissions. In order to support the above model, the token endpoint would need to be able to specify a repository name that permissions are required for (this could be optional).

If the permissions can vary by the [pipeline,repo] tuple, token caching needs to be changed to use this pair as the cache key.

  1. The GitHub token client in internal/github should take a service that supplies the permissions for a given pipeline. This is then supplied to GitHub and the generated token returned.

Thoughts?

@dstrates
Copy link

dstrates commented Jun 6, 2024

This is very well thought out, thanks for the details.

My only suggestion is that while there's no harm including a REPOSITORY_CONFIGURATION_URN environment variable, it may be more intuitive to automatically source configuration from a <config-name>.yaml file located anywhere in the repository?

@jamestelfer
Copy link
Collaborator Author

When you say "the repository" do you mean the repository that the token is being requested for?

That is, a configuration YAML that exists in a single repository of a given organization, or, one config for each repository that may be accessed, stored in that target repository itself?

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

No branches or pull requests

2 participants