Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix(github-org-sync): correct the token permission error and document secret teams
Scott Wilson17d63a830ed7
diff --git a/backend/src/ee/services/github-org-sync/github-org-sync-service.ts b/backend/src/ee/services/github-org-sync/github-org-sync-service.tsindex 8649a335cf..b65e145be3 100644--- a/backend/src/ee/services/github-org-sync/github-org-sync-service.ts+++ b/backend/src/ee/services/github-org-sync/github-org-sync-service.ts@@ -37,6 +37,11 @@ import {const OctokitWithPlugin = Octokit.plugin(paginateGraphql);+// The sync only ever reads from GitHub, so read:org is the whole requirement. Both 403 handlers+// share this so they cannot drift apart again.+const githubTeamAccessDeniedMessage = (githubOrgName: string) =>+ `GitHub denied access to the teams in organization '${githubOrgName}'. A classic access token needs the 'read:org' scope. A fine-grained token needs Organization permissions > Members set to read, with the organization as its resource owner. GitHub also hides secret teams from anyone who is not an organization owner or a member of the team.`;+// GitHub's GraphQL API times out (502) when one page resolves too many nodes; nesting members// under teams multiplies the per-page node count, so the team page is kept small.const GITHUB_TEAMS_PAGE_SIZE = 20;@@ -672,8 +677,7 @@ export const githubOrgSyncServiceFactory = ({}if (statusCode === 403) {throw new BadRequestError({- message:- "GitHub access token lacks required permissions. Required: 1) 'read:org' scope for organization teams, 2) Token owner must be an organization member with team visibility access, 3) Organization settings must allow team visibility. Check GitHub token scopes and organization member permissions."+ message: githubTeamAccessDeniedMessage(config.githubOrgName)});}if (statusCode === 404) {@@ -773,8 +777,7 @@ export const githubOrgSyncServiceFactory = ({}if (statusCode === 403) {throw new BadRequestError({- message:- "GitHub access token lacks required permissions for organization team sync. Required: 1) 'admin:org' scope, 2) Token owner must be organization owner or have team read permissions, 3) Organization settings must allow team visibility. Check token scopes and user role."+ message: githubTeamAccessDeniedMessage(config.githubOrgName)});}if (statusCode === 404) {diff --git a/docs/documentation/platform/github-org-sync.mdx b/docs/documentation/platform/github-org-sync.mdxindex 421ef870d3..9ea6348926 100644--- a/docs/documentation/platform/github-org-sync.mdx+++ b/docs/documentation/platform/github-org-sync.mdx@@ -105,10 +105,17 @@ You can manually synchronize GitHub teams for all organization members who have## Troubleshooting-<Accordion title="Please check if your organization has approved the Infisical OAuth application.">- If you encounter an error related to this, it indicates that you need to approve the Infisical OAuth application within your GitHub organization.+<AccordionGroup>+ <Accordion title="Please check if your organization has approved the Infisical OAuth application.">+ If you encounter an error related to this, it indicates that you need to approve the Infisical OAuth application within your GitHub organization.- You can verify the application's approval status by navigating to **https://github.com/organizations/__your-organization__/settings/oauth_application_policy**. Replace `__your-organization__` with the actual name of your GitHub organization.+ You can verify the application's approval status by navigating to **https://github.com/organizations/__your-organization__/settings/oauth_application_policy**. Replace `__your-organization__` with the actual name of your GitHub organization.- -</Accordion>+ + </Accordion>+ <Accordion title="Why did the sync skip some of my GitHub teams?">+ GitHub shows secret teams only to organization owners and to the team's own members. The manual sync reads the teams the token owner can see, so a sync run with a regular member's token skips every secret team that member doesn't belong to.++ Infisical leaves a skipped team's group alone, so no memberships are lost. To cover every team, create the token as an organization owner.+ </Accordion>+</AccordionGroup>