Fix GitHub App cross-org member enumeration using per-installation tokens#4774
Open
dustin-decker wants to merge 1 commit intomainfrom
Open
Fix GitHub App cross-org member enumeration using per-installation tokens#4774dustin-decker wants to merge 1 commit intomainfrom
dustin-decker wants to merge 1 commit intomainfrom
Conversation
4 tasks
…kens When a GitHub App is installed across multiple orgs, addMembersByApp discovers all installations via JWT but uses a single installation's token to call ListMembers for every org. GitHub App installation tokens only bypass IP allowlists for their own org, causing 403 errors for cross-org calls. Changes: - Add appsTransport and apiEndpoint fields to appConnector - Add APIClientForInstallation method that creates a per-installation API client using ghinstallation.NewFromAppsTransport - Refactor addMembersByApp to create per-installation clients for each discovered org instead of reusing s.connector.APIClient() - Extract addMembersByOrgWithClient so callers can provide an explicit client (addMembersByOrg delegates to it for backward compat) - Update existing tests to pass appConnector and include installation IDs in mock responses - Add new tests for APIClientForInstallation and addMembersByOrgWithClient
07427a9 to
977a541
Compare
rosecodym
reviewed
Mar 2, 2026
| // installation. This is needed when a GitHub App is installed across multiple | ||
| // orgs — each org's API calls must use that org's installation token to get | ||
| // proper IP allowlist bypass and permission scoping. | ||
| func (c *appConnector) APIClientForInstallation(installationID int64) (*github.Client, error) { |
Contributor
There was a problem hiding this comment.
Can this function be used by NewAppConnector? That function creates a new API client for a particular installation ID (the ID specified in the connection information).
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
addMembersByAppdiscovers all installations via JWT but uses a single installation's token forListMemberscalls across all orgsAPIClientForInstallationtoappConnectorwhich creates per-installation API clients usingghinstallation.NewFromAppsTransportaddMembersByOrgWithClientfromaddMembersByOrgso the app auth path can provide an explicit per-installation clientTest plan
APIClientForInstallation(3 subtests verifying distinct clients, correct installation ID, different tokens)addMembersByOrgWithClientTestAddMembersByAppandTestEnumerateWithAppupdated and passinggo buildpassesNote
Cursor Bugbot is generating a summary for commit 977a541. Configure here.