feat(github): restrict app installation tokens to selected repositories - #14
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The change is opt-in, preserves the prior default request behavior, and is covered by targeted unit tests plus corresponding documentation updates.
Pull request overview
Adds an opt-in least-privilege mode for GitHub App installation tokens by allowing callers to restrict minted installation access tokens to a configured set of repository names, while preserving the previous “no request body” behavior by default.
Changes:
- Extended
GitHubAppAuth/AppTokenSourceOptionswith optionalrepositories?: string[]and threaded it through provider construction. - Updated GitHub App token minting to conditionally include a JSON body
{ repositories: [...] }(andContent-Type) only when configured. - Added unit tests and documentation covering both the restricted-token and default no-body behaviors.
File summaries
| File | Description |
|---|---|
| test/providers/github-app.test.ts | Adds test coverage for restricted token mint requests and unchanged default behavior (no body / no Content-Type). |
| src/providers/github/index.ts | Exposes repositories?: string[] on GitHubAppAuth and passes it into the app token source. |
| src/providers/github/app-auth.ts | Implements conditional JSON request body + Content-Type when minting installation tokens with repository restrictions. |
| skills/repo-sdk-auth/SKILL.md | Documents the new optional repositories auth option for GitHub App usage. |
| docs/authentication/github.mdx | Documents repositories in the auth type table and adds a usage section with example. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
|
Deploy preview available at: https://f9ad125f.repo-sdk-page.pages.dev. Built with commit 7f4be0a. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional
repositoriesfield toGitHubAppAuth, so a GitHub App installation access token can be restricted to specific repositories instead of everything the installation can reach.Behaviour
repositoriesis set, the access-token request (POST /app/installations/{id}/access_tokens) is sent with the JSON body{ "repositories": [...] }— the GitHub RESTrepositoriesparameter, repository names without the owner.permissionsorrepository_idssupport — only the repository-name restriction.Motivation: least-privilege tokens for CI consumers that hand the token to build steps.
Tests
Two cases added to
test/providers/github-app.test.ts, mirroring the existing GitHub App token tests:repositories, and the resulting token is the one used for the subsequent repo callContent-Type) whenrepositoriesis omittedDocs
docs/authentication/github.mdx— newrepositoriesrow in the GitHub App authTypeTableplus a short "Restricting the token to specific repositories" sectionskills/repo-sdk-auth/SKILL.md— one bullet under the GitHub App specifics