Skip to content

feat(github): installation tokens administer their account; repository permissions follow GitHub's model - #230

Closed
0xChathurinda wants to merge 1 commit into
vercel-labs:mainfrom
0xChathurinda:feat/github-installation-org-admin
Closed

feat(github): installation tokens administer their account; repository permissions follow GitHub's model#230
0xChathurinda wants to merge 1 commit into
vercel-labs:mainfrom
0xChathurinda:feat/github-installation-org-admin

Conversation

@0xChathurinda

Copy link
Copy Markdown

Summary

Two related fidelity fixes for the GitHub emulator, found while pointing a real GitHub App based provisioning service at it.

Installation tokens can administer the account they are installed on. POST /orgs/:org/repos, PUT/DELETE /repos/:owner/:repo/collaborators/:username and PUT /orgs/:org/memberships/:username resolved the caller as a user (the installation token's login is the account login, which has no user row) and refused every installation. GitHub Apps manage an account through their permission set, not membership, so now:

  • administration: write on the installation lets it create repositories in the account and manage collaborators on repositories it can access
  • members: write lets it manage organization membership
  • anything less is 403, as before

Repository permissions follow GitHub's model. Every organization member was treated as a repository admin (isOrgMember short-circuited hasRepoAdmin and canAccessRepo). Now, via one repoRoleFor resolver:

  • organization owners (maintainers of the members team) hold admin
  • members start from the org's default_repository_permission, which may be none
  • collaborator and team grants raise the role
  • GET /repos/:owner/:repo/collaborators/:username/permission answers for any existing user with the legacy permission scale (admin/write/read/none) and the precise role_name (maintain, triage, ...), returning none rather than 404 when the user has no access. 404 stays for an unknown user.

The seed gains orgs[].default_repository_permission, orgs[].members (with role: admin for owners) and repos[].collaborators, so these situations can be set up without an admin token at start.

Testing

src/__tests__/installation-admin.test.ts covers installation create/collaborator/membership paths with and without the permission, the permission endpoint across owner, member, collaborator, stranger and unknown user, base-permission visibility, owner-vs-member collaborator management, and the new seed keys. The existing 91 tests pass unchanged. Docs: package README seed example and Auth section, root README seed example.

…y permissions follow GitHub's model

A GitHub App installation token could read through the emulator but not
administer anything: POST /orgs/:org/repos, the collaborator routes and
PUT /orgs/:org/memberships all resolved the caller as a user and refused it,
so an App that provisions repositories for an organization could not run
against the emulator at all. Installations now act for the account they are
installed on through their permission set, as on GitHub: administration:
write creates repositories and manages collaborators, members: write manages
organization membership.

Repository permissions also follow GitHub's model instead of treating every
organization member as an admin: owners hold admin, members start from the
org's default_repository_permission (which may be none), collaborator and
team grants raise it, and GET /repos/:owner/:repo/collaborators/:username/
permission answers for any user, with the legacy permission scale and the
precise role_name, returning none rather than 404 for a user without access.

The seed gains orgs[].default_repository_permission, orgs[].members and
repos[].collaborators so those situations can be set up without an admin
token.
@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@0xChathurinda is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@0xChathurinda
0xChathurinda deleted the feat/github-installation-org-admin branch September 7, 2026 02:00
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.

1 participant