fix(github): resolve write actors for org-installed App tokens - #207
Open
yonatangross wants to merge 1 commit into
Open
fix(github): resolve write actors for org-installed App tokens#207yonatangross wants to merge 1 commit into
yonatangross wants to merge 1 commit into
Conversation
An installation token's AuthUser.login is the installation ACCOUNT login. For an App installed on an organization that login is the org, which is not a row in users, so assertRepoWrite/assertIssueWrite (via the user-only assertAuthenticatedUser) answered 401 to every issue, milestone, label, comment and pull-request write. User-account installs only worked by accident: the write was attributed to the account user instead of the app's <slug>[bot] actor. Resolve write actors with assertAuthenticatedActor (installationActor for installations, the user otherwise), and gate issue writes on the installation's issues/pull_requests permission like GitHub does.
Contributor
|
@yonatangross is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
assertRepoWrite/assertIssueWritenow resolve the actor (assertAuthenticatedActor:<slug>[bot]for installation tokens, the user otherwise) instead of the user-onlyassertAuthenticatedUserissues/pull_requestswrite permission, like GitHubWhy
An installation token's
AuthUser.loginis the installation account login. For an App installed on an organization that login is the org, which is not a row inusers, so every issue, milestone, label, comment and pull-request write with an org-installed App token answered 401 "Requires authentication" while reads worked. User-account installs only worked by accident: the write was attributed to the account user rather than the app's[bot]actor thatinstallationActor()already builds.Found while running Yonatan-HQ/platform's emulate tier with the seed's App installed on the org (the prod shape: promote auto-merge writes with an org-installed App).
Changes
route-helpers.tsassertRepoWrite/assertIssueWriteviaassertAuthenticatedActor; installation permission gate on issue writes__tests__/installation-writes.test.tsmy-app[bot]; no-token write still 401Not touched:
pulls.tsupdate-branch still usesassertAuthenticatedUser; same class, left for a separate change to keep this one small.Test plan
pnpm --filter @emulators/github test(5 files pass, 3 new cases)pnpm -r buildpnpm --filter @emulators/github lint(0 errors, no new warnings)