Skip to content

Commit f4af2a2

Browse files
feat: enforce permissions for public repos and store issuerUrl on accounts (#993)
* feat: enforce permissions for public repos and store issuerUrl on accounts - Adds enforcePermissionsForPublicRepos per-connection toggle - Stores issuerUrl on Account at sign-in for public repo permission checks - Updates getRepoPermissionFilterForUser to apply new public repo logic - Cleans up sso.ts provider issuerUrl handling - Updates permission syncing docs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: update CHANGELOG for #993 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs * lazy migration of issuerUrl * supporting comments in the schema * feedback --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ba6e2b4 commit f4af2a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+622
-71
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- [EE] Added `PERMISSION_SYNC_REPO_DRIVEN_ENABLED` environment variable to enable/disable repo-driven permission syncing. [#989](https://github.com/sourcebot-dev/sourcebot/pull/989)
1313
- [EE] Added `enforcePermissions` per-connection flag to control whether repository permissions are enforced for a given connection. Defaults to the value of `PERMISSION_SYNC_ENABLED`. [#991](https://github.com/sourcebot-dev/sourcebot/pull/991)
1414
- [EE] Added `repoDrivenPermissionSyncIntervalMs` and `userDrivenPermissionSyncIntervalMs` config settings, deprecating the `experiment_` prefixed variants (still respected as fallbacks). [#991](https://github.com/sourcebot-dev/sourcebot/pull/991)
15+
- [EE] Added `enforcePermissionsForPublicRepos` per-connection flag to restrict public repository visibility to users with a linked account for that connection's code host. [#993](https://github.com/sourcebot-dev/sourcebot/pull/993)
1516

1617
### Changed
1718
- [EE] Promoted `PERMISSION_SYNC_ENABLED` as the canonical env var for enabling permission syncing, deprecating `EXPERIMENT_EE_PERMISSION_SYNC_ENABLED` (still respected as a fallback). [#991](https://github.com/sourcebot-dev/sourcebot/pull/991)

docs/docs/features/permission-syncing.mdx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,13 @@ The button will show a spinner while the sync is in progress and display a confi
147147

148148
# Overriding enforcement per connection
149149

150-
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.
150+
Each [connection](/docs/connections/overview) supports two flags that control permission enforcement for that connection's repositories:
151151

152-
By default, `enforcePermissions` inherits the value of `PERMISSION_SYNC_ENABLED`. You can override it per connection in the [config file](/docs/configuration/config-file):
152+
- **`enforcePermissions`**: Controls whether repository permissions are enforced for the connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`.
153+
- **`enforcePermissionsForPublicRepos`**: Controls whether repository permissions are enforced for public repositories in the connection. When true, public repositories are only visible to users with a linked account for the connection's code host. When false, public repositories are visible to all users. Has no effect when `enforcePermissions` is false. Defaults to false.
154+
155+
156+
These flags are useful when you want different enforcement behavior across connections. For example, you may want to enforce permissions on an internal GitHub Enterprise connection while leaving a public-facing Gerrit mirror open to all users. Or, you can use `enforcePermissionsForPublicRepos` to restrict public repositories on a Bitbucket connection so that only users who have authenticated with that host can browse them.
153157

154158
```json
155159
{
@@ -158,6 +162,11 @@ By default, `enforcePermissions` inherits the value of `PERMISSION_SYNC_ENABLED`
158162
"type": "github",
159163
"enforcePermissions": true
160164
},
165+
"my-bitbucket": {
166+
"type": "bitbucket",
167+
"enforcePermissions": true,
168+
"enforcePermissionsForPublicRepos": true
169+
},
161170
"my-gerrit": {
162171
"type": "gerrit",
163172
"url": "https://gerrit.example.com",
@@ -167,16 +176,14 @@ By default, `enforcePermissions` inherits the value of `PERMISSION_SYNC_ENABLED`
167176
}
168177
```
169178

170-
Setting `enforcePermissions: false` on a connection makes all repositories from that connection accessible to any user, regardless of the global `PERMISSION_SYNC_ENABLED` setting.
171-
172-
The table below shows when permissions are enforced based on the combination of `PERMISSION_SYNC_ENABLED` and `enforcePermissions`:
179+
The table below shows when permissions are enforced based on the combination of `PERMISSION_SYNC_ENABLED`, `enforcePermissions`, and `enforcePermissionsForPublicRepos`:
173180

174-
| `PERMISSION_SYNC_ENABLED` | `enforcePermissions` | Permissions enforced? |
175-
|--------------------------|---------------------|-----------------------|
176-
| `true` | `true` | Yes |
177-
| `true` | `false` | No |
178-
| `false` | `true` | No |
179-
| `false` | `false` | No |
181+
| `PERMISSION_SYNC_ENABLED` | `enforcePermissions` | `enforcePermissionsForPublicRepos` | Private repos enforced? | Public repos enforced? |
182+
|--------------------------|---------------------|------------------------------------|------------------------|------------------------|
183+
| `true` | `true` | `false` | Yes | No |
184+
| `true` | `true` | `true` | Yes | Yes |
185+
| `true` | `false` | any | No | No |
186+
| `false` | any | any | No | No |
180187

181188
# How it works
182189

docs/snippets/schemas/v3/azuredevops.schema.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@
193193
"enforcePermissions": {
194194
"type": "boolean",
195195
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
196+
},
197+
"enforcePermissionsForPublicRepos": {
198+
"type": "boolean",
199+
"default": false,
200+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
196201
}
197202
},
198203
"required": [

docs/snippets/schemas/v3/bitbucket.schema.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@
166166
"enforcePermissions": {
167167
"type": "boolean",
168168
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
169+
},
170+
"enforcePermissionsForPublicRepos": {
171+
"type": "boolean",
172+
"default": false,
173+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
169174
}
170175
},
171176
"required": [

docs/snippets/schemas/v3/connection.schema.mdx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@
209209
"enforcePermissions": {
210210
"type": "boolean",
211211
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
212+
},
213+
"enforcePermissionsForPublicRepos": {
214+
"type": "boolean",
215+
"default": false,
216+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
212217
}
213218
},
214219
"required": [
@@ -415,6 +420,11 @@
415420
"enforcePermissions": {
416421
"type": "boolean",
417422
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
423+
},
424+
"enforcePermissionsForPublicRepos": {
425+
"type": "boolean",
426+
"default": false,
427+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
418428
}
419429
},
420430
"required": [
@@ -574,6 +584,11 @@
574584
"enforcePermissions": {
575585
"type": "boolean",
576586
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
587+
},
588+
"enforcePermissionsForPublicRepos": {
589+
"type": "boolean",
590+
"default": false,
591+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
577592
}
578593
},
579594
"required": [
@@ -685,6 +700,11 @@
685700
"enforcePermissions": {
686701
"type": "boolean",
687702
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
703+
},
704+
"enforcePermissionsForPublicRepos": {
705+
"type": "boolean",
706+
"default": false,
707+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
688708
}
689709
},
690710
"required": [
@@ -859,6 +879,11 @@
859879
"enforcePermissions": {
860880
"type": "boolean",
861881
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
882+
},
883+
"enforcePermissionsForPublicRepos": {
884+
"type": "boolean",
885+
"default": false,
886+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
862887
}
863888
},
864889
"required": [
@@ -1071,6 +1096,11 @@
10711096
"enforcePermissions": {
10721097
"type": "boolean",
10731098
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
1099+
},
1100+
"enforcePermissionsForPublicRepos": {
1101+
"type": "boolean",
1102+
"default": false,
1103+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
10741104
}
10751105
},
10761106
"required": [
@@ -1144,6 +1174,11 @@
11441174
"enforcePermissions": {
11451175
"type": "boolean",
11461176
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
1177+
},
1178+
"enforcePermissionsForPublicRepos": {
1179+
"type": "boolean",
1180+
"default": false,
1181+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
11471182
}
11481183
},
11491184
"required": [

docs/snippets/schemas/v3/genericGitHost.schema.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@
6464
"enforcePermissions": {
6565
"type": "boolean",
6666
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
67+
},
68+
"enforcePermissionsForPublicRepos": {
69+
"type": "boolean",
70+
"default": false,
71+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
6772
}
6873
},
6974
"required": [

docs/snippets/schemas/v3/gerrit.schema.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@
104104
"enforcePermissions": {
105105
"type": "boolean",
106106
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
107+
},
108+
"enforcePermissionsForPublicRepos": {
109+
"type": "boolean",
110+
"default": false,
111+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
107112
}
108113
},
109114
"required": [

docs/snippets/schemas/v3/gitea.schema.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@
152152
"enforcePermissions": {
153153
"type": "boolean",
154154
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
155+
},
156+
"enforcePermissionsForPublicRepos": {
157+
"type": "boolean",
158+
"default": false,
159+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
155160
}
156161
},
157162
"required": [

docs/snippets/schemas/v3/github.schema.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@
205205
"enforcePermissions": {
206206
"type": "boolean",
207207
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
208+
},
209+
"enforcePermissionsForPublicRepos": {
210+
"type": "boolean",
211+
"default": false,
212+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
208213
}
209214
},
210215
"required": [

docs/snippets/schemas/v3/gitlab.schema.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@
199199
"enforcePermissions": {
200200
"type": "boolean",
201201
"description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
202+
},
203+
"enforcePermissionsForPublicRepos": {
204+
"type": "boolean",
205+
"default": false,
206+
"description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
202207
}
203208
},
204209
"required": [

0 commit comments

Comments
 (0)