Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 364
feat: add per-connection enforcePermissions toggle and promote PERMISSION_SYNC_ENABLED#991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
brendan-kellam
merged 4 commits into
main
from
brendan/per-connection-enforce-permissions-SOU-366Mar 10, 2026
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0653396
feat(worker): add per-connection enforcePermissions toggle and promot…
brendan-kellam dd6f825
chore: update CHANGELOG for #991
brendan-kellam 5d0d60d
feat: add repoDrivenPermissionSyncIntervalMs and userDrivenPermission…
brendan-kellam 7516ae6
feedback
brendan-kellam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -45,8 +45,9 @@ The following environment variables allow you to configure your Sourcebot deploy | ||
| | `SOURCEBOT_EE_AUDIT_RETENTION_DAYS` | `180` | <p>The number of days to retain audit logs. Audit log records older than this will be automatically pruned daily. Set to `0` to disable pruning and retain logs indefinitely.</p> | | ||
| | `AUTH_EE_GCP_IAP_ENABLED` | `false` | <p>When enabled, allows Sourcebot to automatically register/login from a successful GCP IAP redirect</p> | | ||
| | `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> | | ||
| | `EXPERIMENT_EE_PERMISSION_SYNC_ENABLED` | `false` | <p>Enables [permission syncing](/docs/features/permission-syncing).</p> | | ||
| | `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> | | ||
| | `PERMISSION_SYNC_ENABLED` | `false` | <p>Enables [permission syncing](/docs/features/permission-syncing).</p> | | ||
| | `PERMISSION_SYNC_REPO_DRIVEN_ENABLED` | `true` | <p>Enables/disables [repo-driven permission syncing](/docs/features/permission-syncing#how-it-works). Only applies when `PERMISSION_SYNC_ENABLED` is `true`.</p> | | ||
brendan-kellam marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| | `EXPERIMENT_EE_PERMISSION_SYNC_ENABLED` **(deprecated)** | `false` | <p>Deprecated. Use `PERMISSION_SYNC_ENABLED` instead.</p> | | ||
| | `AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING` | `true` | <p>When enabled, different SSO accounts with the same email address will automatically be linked.</p> | | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -18,11 +18,11 @@ that they have access to on the code host. Practically, this means: | ||
| - Ask Sourcebot (and the underlying LLM) will only have access to repositories that the user has access to. | ||
| - File browsing is scoped to the repositories that the user has access to. | ||
| Permission syncing can be enabled by setting the `EXPERIMENT_EE_PERMISSION_SYNC_ENABLED` environment variable to `true`. | ||
| Permission syncing can be enabled by setting the `PERMISSION_SYNC_ENABLED` environment variable to `true`. | ||
| ```bash | ||
| docker run \ | ||
| -e EXPERIMENT_EE_PERMISSION_SYNC_ENABLED=true \ | ||
| -e PERMISSION_SYNC_ENABLED=true \ | ||
| /* additional args */ \ | ||
| ghcr.io/sourcebot-dev/sourcebot:latest | ||
| ``` | ||
| @@ -97,9 +97,9 @@ Permission syncing works with **Bitbucket Cloud**. OAuth tokens must assume the | ||
| - Membership in the [project that contains the repository](https://support.atlassian.com/bitbucket-cloud/docs/configure-project-permissions-for-users-and-groups/) | ||
| - Membership in a group that is part of a project containing the repository | ||
| These users **will** still gain access via [user-driven syncing](/docs/features/permission-syncing#how-it-works), which fetches all private repositories accessible to each authenticated user. However, there may be a delay between when a repository is added and when affected users gain access in Sourcebot (up to the `experiment_userDrivenPermissionSyncIntervalMs` interval, which defaults to 24 hours). | ||
| These users **will** still gain access via [user-driven syncing](/docs/features/permission-syncing#how-it-works), which fetches all private repositories accessible to each authenticated user. However, there may be a delay between when a repository is added and when affected users gain access in Sourcebot (up to the `userDrivenPermissionSyncIntervalMs` interval, which defaults to 24 hours). | ||
| If your workspace relies heavily on group or project-level permissions rather than direct user grants, we recommend reducing the `experiment_userDrivenPermissionSyncIntervalMs` interval to limit the window of delay. | ||
| If your workspace relies heavily on group or project-level permissions rather than direct user grants, we recommend reducing the `userDrivenPermissionSyncIntervalMs` interval to limit the window of delay. | ||
| </Warning> | ||
| **Notes:** | ||
| @@ -120,16 +120,64 @@ Permission syncing works with **Bitbucket Data Center**. OAuth tokens must assum | ||
| - Project-level permissions (inherited by all repos in the project) | ||
| - Group membership | ||
| These users **will** still gain access via [user-driven syncing](/docs/features/permission-syncing#how-it-works), which fetches all repositories accessible to each authenticated user using the `REPO_READ` scope. However, there may be a delay between when access is granted and when affected users see the repository in Sourcebot (up to the `experiment_userDrivenPermissionSyncIntervalMs` interval, which defaults to 24 hours). | ||
| These users **will** still gain access via [user-driven syncing](/docs/features/permission-syncing#how-it-works), which fetches all repositories accessible to each authenticated user using the `REPO_READ` scope. However, there may be a delay between when access is granted and when affected users see the repository in Sourcebot (up to the `userDrivenPermissionSyncIntervalMs` interval, which defaults to 24 hours). | ||
| If your instance relies heavily on project or group-level permissions, we recommend reducing the `experiment_userDrivenPermissionSyncIntervalMs` interval to limit the window of delay. | ||
| If your instance relies heavily on project or group-level permissions, we recommend reducing the `userDrivenPermissionSyncIntervalMs` interval to limit the window of delay. | ||
| </Warning> | ||
| **Notes:** | ||
| - A Bitbucket Data Center [external identity provider](/docs/configuration/idp#bitbucket-server) must be configured to (1) correlate a Sourcebot user with a Bitbucket Data Center user, and (2) to list repositories that the user has access to for [User driven syncing](/docs/features/permission-syncing#how-it-works). | ||
| - The connection token must have **Repository Read** permissions so Sourcebot can read repository-level user permissions for [Repo driven syncing](/docs/features/permission-syncing#how-it-works). | ||
| - OAuth tokens require the `REPO_READ` scope to list accessible repositories during [User driven syncing](/docs/features/permission-syncing#how-it-works). | ||
| # Manually refreshing permissions | ||
| If a user's permissions have changed and they need access updated immediately (without waiting for the next scheduled sync), they can trigger a manual refresh from the **Linked Accounts** page: | ||
| 1. Navigate to **Settings → Linked Accounts**. | ||
| 2. Click the **Connected** button next to the relevant code host account. | ||
| 3. Select **Refresh Permissions** from the dropdown. | ||
| <Frame> | ||
| <img src="/images/linked_accounts_refresh_permissions.png" alt="Linked Accounts - Refresh Permissions" /> | ||
| </Frame> | ||
| The button will show a spinner while the sync is in progress and display a confirmation once it completes. | ||
| # Overriding enforcement per connection | ||
| Each [connection](/docs/connections/overview) supports an `enforcePermissions` flag that controls whether permissions are enforced for repositories in that connection. This lets you mix code hosts in a single deployment - for example, enforcing access control on a private GitHub connection while keeping an internal Gerrit instance open to all users. | ||
| By default, `enforcePermissions` inherits the value of `PERMISSION_SYNC_ENABLED`. You can override it per connection in the [config file](/docs/configuration/config-file): | ||
| ```json | ||
| { | ||
| "connections": { | ||
| "my-github": { | ||
| "type": "github", | ||
| "enforcePermissions": true | ||
| }, | ||
| "my-gerrit": { | ||
| "type": "gerrit", | ||
| "url": "https://gerrit.example.com", | ||
| "enforcePermissions": false | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
| Setting `enforcePermissions: false` on a connection makes all repositories from that connection accessible to any user, regardless of the global `PERMISSION_SYNC_ENABLED` setting. | ||
| The table below shows when permissions are enforced based on the combination of `PERMISSION_SYNC_ENABLED` and `enforcePermissions`: | ||
| | `PERMISSION_SYNC_ENABLED` | `enforcePermissions` | Permissions enforced? | | ||
| |--------------------------|---------------------|-----------------------| | ||
| | `true` | `true` | Yes | | ||
| | `true` | `false` | No | | ||
| | `false` | `true` | No | | ||
| | `false` | `false` | No | | ||
brendan-kellam marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| # How it works | ||
| Permission syncing works by periodically syncing ACLs from the code host(s) to Sourcebot to build an internal mapping between Users and Repositories. This mapping is hydrated in two directions: | ||
| @@ -146,19 +194,5 @@ The sync intervals can be configured using the following settings in the [config | ||
| | Setting | Type | Default | Minimum | | ||
| |-------------------------------------------------|---------|------------|---------| | ||
| | `experiment_repoDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 | | ||
| | `experiment_userDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 | | ||
| ## Manually refreshing permissions | ||
| If a user's permissions have changed and they need access updated immediately (without waiting for the next scheduled sync), they can trigger a manual refresh from the **Linked Accounts** page: | ||
| 1. Navigate to **Settings → Linked Accounts**. | ||
| 2. Click the **Connected** button next to the relevant code host account. | ||
| 3. Select **Refresh Permissions** from the dropdown. | ||
| <Frame> | ||
| <img src="/images/linked_accounts_refresh_permissions.png" alt="Linked Accounts - Refresh Permissions" /> | ||
| </Frame> | ||
| The button will show a spinner while the sync is in progress and display a confirmation once it completes. | ||
| | `repoDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 | | ||
| | `userDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 | | ||
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
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
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
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
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
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
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
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
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.