Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(auth): Add AUTH_CUSTOM_ID_TOKEN environment variable (#5193)

mariusp1250f9444c36eb
diff --git a/.env.prod.example b/.env.prod.example
index 3f591ea776..66f1f271f7 100644
--- a/.env.prod.example
+++ b/.env.prod.example
@@ -103,6 +103,7 @@ OTEL_SERVICE_NAME="langfuse"
# AUTH_CUSTOM_SCOPE="openid email profile" # optional
# AUTH_CUSTOM_CLIENT_AUTH_METHOD="client_secret_basic" # optional
# AUTH_CUSTOM_ALLOW_ACCOUNT_LINKING=false
+# AUTH_CUSTOM_ID_TOKEN=false # optional, default is true
# Transactional email, optional
# Defines the email address to use as the from address.
@@ -253,4 +254,4 @@ OTEL_SERVICE_NAME="langfuse"
# LANGFUSE_INGESTION_CLICKHOUSE_WRITE_INTERVAL_MS=
# LANGFUSE_INGESTION_CLICKHOUSE_MAX_ATTEMPTS=
-## END Langfuse V3 Ingestion
\ No newline at end of file
+## END Langfuse V3 Ingestion
diff --git a/packages/shared/src/server/auth/customSsoProvider.ts b/packages/shared/src/server/auth/customSsoProvider.ts
index 97f9bbf9e2..55365815de 100644
--- a/packages/shared/src/server/auth/customSsoProvider.ts
+++ b/packages/shared/src/server/auth/customSsoProvider.ts
@@ -17,7 +17,6 @@ export function CustomSSOProvider<P extends CustomSSOUser>(
wellKnown: `${options.issuer}/.well-known/openid-configuration`,
authorization: { params: { scope: "openid email profile" } }, // overridden by options.authorization to be able to set custom scopes, deep merged with this default
checks: ["pkce", "state"],
- idToken: true,
profile(profile) {
return {
id: profile.sub,
diff --git a/web/src/ee/features/multi-tenant-sso/types.ts b/web/src/ee/features/multi-tenant-sso/types.ts
index a067527a12..fabf77678e 100644
--- a/web/src/ee/features/multi-tenant-sso/types.ts
+++ b/web/src/ee/features/multi-tenant-sso/types.ts
@@ -29,17 +29,17 @@ export const GithubProviderSchema = base.extend({
});
export const GithubEnterpriseProviderSchema = base.extend({
- authProvider: z.literal("github-enterprise"),
- authConfig: z
- .object({
- clientId: z.string(),
- clientSecret: z.string(),
- enterprise: z.object({
- baseUrl: z.string().url(),
- }),
- allowDangerousEmailAccountLinking: z.boolean().optional().default(false),
- })
- .nullish(),
+ authProvider: z.literal("github-enterprise"),
+ authConfig: z
+ .object({
+ clientId: z.string(),
+ clientSecret: z.string(),
+ enterprise: z.object({
+ baseUrl: z.string().url(),
+ }),
+ allowDangerousEmailAccountLinking: z.boolean().optional().default(false),
+ })
+ .nullish(),
});
export const GitlabProviderSchema = base.extend({
@@ -123,6 +123,7 @@ export const CustomProviderSchema = base.extend({
clientSecret: z.string(),
issuer: z.string(),
scope: z.string().nullish(),
+ idToken: z.boolean().optional().default(true),
allowDangerousEmailAccountLinking: z.boolean().optional().default(false),
})
.nullish(),
@@ -130,7 +131,9 @@ export const CustomProviderSchema = base.extend({
export type GoogleProviderSchema = z.infer<typeof GoogleProviderSchema>;
export type GithubProviderSchema = z.infer<typeof GithubProviderSchema>;
-export type GithubEnterpriseProviderSchema = z.infer<typeof GithubEnterpriseProviderSchema>;
+export type GithubEnterpriseProviderSchema = z.infer<
+ typeof GithubEnterpriseProviderSchema
+>;
export type GitlabProviderSchema = z.infer<typeof GitlabProviderSchema>;
export type Auth0ProviderSchema = z.infer<typeof Auth0ProviderSchema>;
export type OktaProviderSchema = z.infer<typeof OktaProviderSchema>;
diff --git a/web/src/env.mjs b/web/src/env.mjs
index 903a54268c..3567163c40 100644
--- a/web/src/env.mjs
+++ b/web/src/env.mjs
@@ -108,6 +108,7 @@ export const env = createEnv({
])
.optional(),
AUTH_CUSTOM_ALLOW_ACCOUNT_LINKING: z.enum(["true", "false"]).optional(),
+ AUTH_CUSTOM_ID_TOKEN: z.enum(["true", "false"]).optional(),
AUTH_DOMAINS_WITH_SSO_ENFORCEMENT: z.string().optional(),
AUTH_IGNORE_ACCOUNT_FIELDS: z.string().optional(),
AUTH_DISABLE_USERNAME_PASSWORD: z.enum(["true", "false"]).optional(),
@@ -365,6 +366,7 @@ export const env = createEnv({
AUTH_CUSTOM_CLIENT_AUTH_METHOD: process.env.AUTH_CUSTOM_CLIENT_AUTH_METHOD,
AUTH_CUSTOM_ALLOW_ACCOUNT_LINKING:
process.env.AUTH_CUSTOM_ALLOW_ACCOUNT_LINKING,
+ AUTH_CUSTOM_ID_TOKEN: process.env.AUTH_CUSTOM_ID_TOKEN,
AUTH_IGNORE_ACCOUNT_FIELDS: process.env.AUTH_IGNORE_ACCOUNT_FIELDS,
AUTH_DOMAINS_WITH_SSO_ENFORCEMENT:
process.env.AUTH_DOMAINS_WITH_SSO_ENFORCEMENT,
diff --git a/web/src/server/auth.ts b/web/src/server/auth.ts
index 54f2005e61..d913b50bcb 100644
--- a/web/src/server/auth.ts
+++ b/web/src/server/auth.ts
@@ -184,6 +184,7 @@ if (
clientId: env.AUTH_CUSTOM_CLIENT_ID,
clientSecret: env.AUTH_CUSTOM_CLIENT_SECRET,
issuer: env.AUTH_CUSTOM_ISSUER,
+ idToken: env.AUTH_CUSTOM_ID_TOKEN !== "false", // defaults to true
allowDangerousEmailAccountLinking:
env.AUTH_CUSTOM_ALLOW_ACCOUNT_LINKING === "true",
authorization: {