Skip to content

Commit 61659f9

Browse files
fix(web): Add AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING (#849)
1 parent 4d37b18 commit 61659f9

4 files changed

Lines changed: 26 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Fixed issue where file references in copied chat answers were relative paths instead of full browse URLs. [#847](https://github.com/sourcebot-dev/sourcebot/pull/847)
1313
- [EE] Fixed issue where account driven permission syncing would fail when attempting to authenticate with a GitHub App user token. [#850](https://github.com/sourcebot-dev/sourcebot/pull/850)
1414

15+
### Added
16+
- [EE] Added `AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING` env var that, when enabled, will automatically link SSO accounts with the same email address. [#849](https://github.com/sourcebot-dev/sourcebot/pull/849)
17+
1518
## [4.10.24] - 2026-02-03
1619

1720
### Fixed

docs/docs/configuration/environment-variables.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ The following environment variables allow you to configure your Sourcebot deploy
6262
| `AUTH_EE_GCP_IAP_ENABLED` | `false` | <p>When enabled, allows Sourcebot to automatically register/login from a successful GCP IAP redirect</p> |
6363
| `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> |
6464
| `EXPERIMENT_EE_PERMISSION_SYNC_ENABLED` | `false` | <p>Enables [permission syncing](/docs/features/permission-syncing).</p> |
65+
| `AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING` | `false` | <p>When enabled, different SSO accounts with the same email address will automatically be linked.</p> |
6566

6667

6768
### Review Agent Environment Variables

packages/shared/src/env.server.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ export const env = createEnv({
140140
AUTH_EMAIL_CODE_LOGIN_ENABLED: booleanSchema.default('false'),
141141

142142
// Enterprise Auth
143+
144+
AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING:
145+
booleanSchema
146+
.default('false')
147+
.describe('When enabled, different SSO accounts with the same email address will automatically be linked.'),
148+
143149
AUTH_EE_GITHUB_CLIENT_ID: z.string().optional(),
144150
AUTH_EE_GITHUB_CLIENT_SECRET: z.string().optional(),
145151
AUTH_EE_GITHUB_BASE_URL: z.string().optional(),

packages/web/src/ee/features/sso/sso.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ const createGitHubProvider = (clientId: string, clientSecret: string, baseUrl?:
139139
].join(' '),
140140
},
141141
},
142+
allowDangerousEmailAccountLinking: env.AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING === 'true',
142143
});
143144
}
144145

@@ -168,13 +169,15 @@ const createGitLabProvider = (clientId: string, clientSecret: string, baseUrl?:
168169
userinfo: {
169170
url: `${url}/api/v4/user`,
170171
},
172+
allowDangerousEmailAccountLinking: env.AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING === 'true',
171173
});
172174
}
173175

174176
const createGoogleProvider = (clientId: string, clientSecret: string): Provider => {
175177
return Google({
176178
clientId: clientId,
177179
clientSecret: clientSecret,
180+
allowDangerousEmailAccountLinking: env.AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING === 'true',
178181
});
179182
}
180183

@@ -183,6 +186,7 @@ const createOktaProvider = (clientId: string, clientSecret: string, issuer: stri
183186
clientId: clientId,
184187
clientSecret: clientSecret,
185188
issuer: issuer,
189+
allowDangerousEmailAccountLinking: env.AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING === 'true',
186190
});
187191
}
188192

@@ -191,6 +195,7 @@ const createKeycloakProvider = (clientId: string, clientSecret: string, issuer:
191195
clientId: clientId,
192196
clientSecret: clientSecret,
193197
issuer: issuer,
198+
allowDangerousEmailAccountLinking: env.AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING === 'true',
194199
});
195200
}
196201

@@ -199,6 +204,16 @@ const createMicrosoftEntraIDProvider = (clientId: string, clientSecret: string,
199204
clientId: clientId,
200205
clientSecret: clientSecret,
201206
issuer: issuer,
207+
allowDangerousEmailAccountLinking: env.AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING === 'true',
208+
});
209+
}
210+
211+
export const createAuthentikProvider = (clientId: string, clientSecret: string, issuer: string): Provider => {
212+
return Authentik({
213+
clientId: clientId,
214+
clientSecret: clientSecret,
215+
issuer: issuer,
216+
allowDangerousEmailAccountLinking: env.AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING === 'true',
202217
});
203218
}
204219

@@ -207,7 +222,7 @@ const createGCPIAPProvider = (audience: string): Provider => {
207222
id: "gcp-iap",
208223
name: "Google Cloud IAP",
209224
credentials: {},
210-
authorize: async (credentials, req) => {
225+
authorize: async (_credentials, req) => {
211226
try {
212227
const iapAssertion = req.headers?.get("x-goog-iap-jwt-assertion");
213228
if (!iapAssertion || typeof iapAssertion !== "string") {
@@ -277,11 +292,3 @@ const createGCPIAPProvider = (audience: string): Provider => {
277292
},
278293
});
279294
}
280-
281-
export const createAuthentikProvider = (clientId: string, clientSecret: string, issuer: string): Provider => {
282-
return Authentik({
283-
clientId: clientId,
284-
clientSecret: clientSecret,
285-
issuer: issuer,
286-
});
287-
}

0 commit comments

Comments
 (0)