Skip to content

Commit 4f512d3

Browse files
wip
1 parent 9c56827 commit 4f512d3

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

packages/shared/src/env.server.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ export const env = createEnv({
138138
AUTH_URL: z.string().url(),
139139
AUTH_CREDENTIALS_LOGIN_ENABLED: booleanSchema.default('true'),
140140
AUTH_EMAIL_CODE_LOGIN_ENABLED: booleanSchema.default('false'),
141-
141+
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)