Skip to content

Commit 5cc364d

Browse files
feat(backend): add env vars to independently enable/disable user and repo driven permission syncing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fc90833 commit 5cc364d

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

docs/docs/configuration/environment-variables.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ The following environment variables allow you to configure your Sourcebot deploy
4646
| `AUTH_EE_GCP_IAP_ENABLED` | `false` | <p>When enabled, allows Sourcebot to automatically register/login from a successful GCP IAP redirect</p> |
4747
| `AUTH_EE_GCP_IAP_AUDIENCE` | - | <p>The GCP IAP audience to use when verifying JWT tokens. Must be set to enable GCP IAP JIT provisioning</p> |
4848
| `EXPERIMENT_EE_PERMISSION_SYNC_ENABLED` | `false` | <p>Enables [permission syncing](/docs/features/permission-syncing).</p> |
49+
| `PERMISSION_SYNC_USER_DRIVEN_ENABLED` | `true` | <p>Enables/disables [user-driven permission syncing](/docs/features/permission-syncing#how-it-works). Only applies when `EXPERIMENT_EE_PERMISSION_SYNC_ENABLED` is `true`.</p> |
50+
| `PERMISSION_SYNC_REPO_DRIVEN_ENABLED` | `true` | <p>Enables/disables [repo-driven permission syncing](/docs/features/permission-syncing#how-it-works). Only applies when `EXPERIMENT_EE_PERMISSION_SYNC_ENABLED` is `true`.</p> |
4951
| `AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING` | `true` | <p>When enabled, different SSO accounts with the same email address will automatically be linked.</p> |
5052

5153

docs/docs/features/permission-syncing.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,15 @@ Permission syncing works by periodically syncing ACLs from the code host(s) to S
134134
- **User driven** : fetches the list of all repositories that a given user has access to.
135135
- **Repo driven** : fetches the list of all users that have access to a given repository.
136136

137-
User driven and repo driven syncing occurs every 24 hours by default. These intervals can be configured using the following settings in the [config file](/docs/configuration/config-file):
137+
User driven and repo driven syncing occurs every 24 hours by default. Each sync direction can be independently enabled or disabled using the following environment variables:
138+
139+
| Environment variable | Default | Description |
140+
|---|---|---|
141+
| `PERMISSION_SYNC_USER_DRIVEN_ENABLED` | `true` | Enables/disables user-driven syncing. |
142+
| `PERMISSION_SYNC_REPO_DRIVEN_ENABLED` | `true` | Enables/disables repo-driven syncing. |
143+
144+
The sync intervals can be configured using the following settings in the [config file](/docs/configuration/config-file):
145+
138146
| Setting | Type | Default | Minimum |
139147
|-------------------------------------------------|---------|------------|---------|
140148
| `experiment_repoDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 |

packages/backend/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ if (env.EXPERIMENT_EE_PERMISSION_SYNC_ENABLED === 'true' && !hasEntitlement('per
7676
process.exit(1);
7777
}
7878
else if (env.EXPERIMENT_EE_PERMISSION_SYNC_ENABLED === 'true' && hasEntitlement('permission-syncing')) {
79-
repoPermissionSyncer.startScheduler();
80-
accountPermissionSyncer.startScheduler();
79+
if (env.PERMISSION_SYNC_REPO_DRIVEN_ENABLED === 'true') {
80+
repoPermissionSyncer.startScheduler();
81+
}
82+
if (env.PERMISSION_SYNC_USER_DRIVEN_ENABLED === 'true') {
83+
accountPermissionSyncer.startScheduler();
84+
}
8185
}
8286

8387
const api = new Api(

packages/shared/src/env.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ export const env = createEnv({
247247
// @NOTE: Take care to update actions.ts when changing the name of this.
248248
EXPERIMENT_SELF_SERVE_REPO_INDEXING_GITHUB_TOKEN: z.string().optional(),
249249
EXPERIMENT_EE_PERMISSION_SYNC_ENABLED: booleanSchema.default('false'),
250+
PERMISSION_SYNC_USER_DRIVEN_ENABLED: booleanSchema.default('true'),
251+
PERMISSION_SYNC_REPO_DRIVEN_ENABLED: booleanSchema.default('true'),
250252
EXPERIMENT_ASK_GH_ENABLED: booleanSchema.default('false'),
251253

252254
SOURCEBOT_ENCRYPTION_KEY: z.string(),

0 commit comments

Comments
 (0)