🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat: Gitlab Auth Provider (#3564)
Vansh Chopra59de94786580
diff --git a/.env.prod.example b/.env.prod.exampleindex d742db9229..5716113f90 100644--- a/.env.prod.example+++ b/.env.prod.example@@ -67,6 +67,9 @@ OTEL_SERVICE_NAME="langfuse"# AUTH_GITHUB_CLIENT_ID=# AUTH_GITHUB_CLIENT_SECRET=# AUTH_GITHUB_ALLOW_ACCOUNT_LINKING=false+# AUTH_GITLAB_CLIENT_ID=+# AUTH_GITLAB_CLIENT_SECRET=+# AUTH_GITLAB_ALLOW_ACCOUNT_LINKING=false# AUTH_AZURE_AD_CLIENT_ID=# AUTH_AZURE_AD_CLIENT_SECRET=# AUTH_AZURE_AD_TENANT_ID=diff --git a/web/src/ee/features/multi-tenant-sso/types.ts b/web/src/ee/features/multi-tenant-sso/types.tsindex 080d8433fa..23083b65c8 100644--- a/web/src/ee/features/multi-tenant-sso/types.ts+++ b/web/src/ee/features/multi-tenant-sso/types.ts@@ -28,6 +28,17 @@ export const GithubProviderSchema = base.extend({.nullish(),});+export const GitlabProviderSchema = base.extend({+ authProvider: z.literal("gitlab"),+ authConfig: z+ .object({+ clientId: z.string(),+ clientSecret: z.string(),+ allowDangerousEmailAccountLinking: z.boolean().optional().default(false),+ })+ .nullish(),+});+export const Auth0ProviderSchema = base.extend({authProvider: z.literal("auth0"),authConfig: z@@ -92,6 +103,7 @@ export const CustomProviderSchema = base.extend({export type GoogleProviderSchema = z.infer<typeof GoogleProviderSchema>;export type GithubProviderSchema = z.infer<typeof GithubProviderSchema>;+export type GitlabProviderSchema = z.infer<typeof GitlabProviderSchema>;export type Auth0ProviderSchema = z.infer<typeof Auth0ProviderSchema>;export type OktaProviderSchema = z.infer<typeof OktaProviderSchema>;export type AzureAdProviderSchema = z.infer<typeof AzureAdProviderSchema>;@@ -101,6 +113,7 @@ export type CustomProviderSchema = z.infer<typeof CustomProviderSchema>;export const SsoProviderSchema = z.discriminatedUnion("authProvider", [GoogleProviderSchema,GithubProviderSchema,+ GitlabProviderSchema,Auth0ProviderSchema,OktaProviderSchema,AzureAdProviderSchema,diff --git a/web/src/ee/features/multi-tenant-sso/utils.ts b/web/src/ee/features/multi-tenant-sso/utils.tsindex 1a0fbd1274..bef842ec10 100644--- a/web/src/ee/features/multi-tenant-sso/utils.ts+++ b/web/src/ee/features/multi-tenant-sso/utils.ts@@ -1,6 +1,7 @@import { type Provider } from "next-auth/providers/index";import GoogleProvider from "next-auth/providers/google";import GitHubProvider from "next-auth/providers/github";+import GitLabProvider from "next-auth/providers/gitlab";import OktaProvider from "next-auth/providers/okta";import CognitoProvider from "next-auth/providers/cognito";import Auth0Provider from "next-auth/providers/auth0";@@ -157,6 +158,12 @@ const dbToNextAuthProvider = (provider: SsoProviderSchema): Provider | null => {...provider.authConfig,clientSecret: decrypt(provider.authConfig.clientSecret),});+ else if (provider.authProvider === "gitlab")+ return GitLabProvider({+ id: getAuthProviderIdForSsoConfig(provider), // use the domain as the provider id as we use domain-specific credentials+ ...provider.authConfig,+ clientSecret: decrypt(provider.authConfig.clientSecret),+ });else if (provider.authProvider === "auth0")return Auth0Provider({id: getAuthProviderIdForSsoConfig(provider), // use the domain as the provider id as we use domain-specific credentialsdiff --git a/web/src/env.mjs b/web/src/env.mjsindex d6739b85ee..69b2307fdd 100644--- a/web/src/env.mjs+++ b/web/src/env.mjs@@ -55,6 +55,9 @@ export const env = createEnv({AUTH_GITHUB_CLIENT_ID: z.string().optional(),AUTH_GITHUB_CLIENT_SECRET: z.string().optional(),AUTH_GITHUB_ALLOW_ACCOUNT_LINKING: z.enum(["true", "false"]).optional(),+ AUTH_GITLAB_CLIENT_ID: z.string().optional(),+ AUTH_GITLAB_CLIENT_SECRET: z.string().optional(),+ AUTH_GITLAB_ALLOW_ACCOUNT_LINKING: z.enum(["true", "false"]).optional(),AUTH_AZURE_AD_CLIENT_ID: z.string().optional(),AUTH_AZURE_AD_CLIENT_SECRET: z.string().optional(),AUTH_AZURE_AD_TENANT_ID: z.string().optional(),@@ -126,7 +129,9 @@ export const env = createEnv({LANGFUSE_UI_FEEDBACK_HREF: z.string().url().optional(),LANGFUSE_UI_LOGO_LIGHT_MODE_HREF: z.string().url().optional(),LANGFUSE_UI_LOGO_DARK_MODE_HREF: z.string().url().optional(),- LANGFUSE_UI_DEFAULT_MODEL_ADAPTER: z.enum(["OpenAI", "Anthropic", "Azure"]).optional(),+ LANGFUSE_UI_DEFAULT_MODEL_ADAPTER: z+ .enum(["OpenAI", "Anthropic", "Azure"])+ .optional(),LANGFUSE_UI_DEFAULT_BASE_URL_OPENAI: z.string().url().optional(),LANGFUSE_UI_DEFAULT_BASE_URL_ANTHROPIC: z.string().url().optional(),LANGFUSE_UI_DEFAULT_BASE_URL_AZURE: z.string().url().optional(),@@ -267,6 +272,10 @@ export const env = createEnv({AUTH_GITHUB_CLIENT_SECRET: process.env.AUTH_GITHUB_CLIENT_SECRET,AUTH_GITHUB_ALLOW_ACCOUNT_LINKING:process.env.AUTH_GITHUB_ALLOW_ACCOUNT_LINKING,+ AUTH_GITLAB_CLIENT_ID: process.env.AUTH_GITLAB_CLIENT_ID,+ AUTH_GITLAB_CLIENT_SECRET: process.env.AUTH_GITLAB_CLIENT_SECRET,+ AUTH_GITLAB_ALLOW_ACCOUNT_LINKING:+ process.env.AUTH_GITLAB_ALLOW_ACCOUNT_LINKING,AUTH_AZURE_AD_CLIENT_ID: process.env.AUTH_AZURE_AD_CLIENT_ID,AUTH_AZURE_AD_CLIENT_SECRET: process.env.AUTH_AZURE_AD_CLIENT_SECRET,AUTH_AZURE_AD_TENANT_ID: process.env.AUTH_AZURE_AD_TENANT_ID,diff --git a/web/src/features/auth-credentials/components/ResetPasswordPage.tsx b/web/src/features/auth-credentials/components/ResetPasswordPage.tsxindex 750e89de7d..fd0930f648 100644--- a/web/src/features/auth-credentials/components/ResetPasswordPage.tsx+++ b/web/src/features/auth-credentials/components/ResetPasswordPage.tsx@@ -240,7 +240,7 @@ export function ResetPasswordPage({<div className="mx-auto mt-10 max-w-lg text-center text-xs text-muted-foreground">You will only receive an email if an account with this email existsand you have signed up with email and password. If you used an- authentication provider like Google, Okta, or GitHub, please{" "}+ authentication provider like Google, Gitlab, Okta, or GitHub, please{" "}<Link href="/auth/sign-in" className="underline">sign in</Link>diff --git a/web/src/pages/auth/sign-in.tsx b/web/src/pages/auth/sign-in.tsxindex 69c8edf86b..483c61d399 100644--- a/web/src/pages/auth/sign-in.tsx+++ b/web/src/pages/auth/sign-in.tsx@@ -13,7 +13,7 @@ import { Input } from "@/src/components/ui/input";import { env } from "@/src/env.mjs";import { zodResolver } from "@hookform/resolvers/zod";import { FcGoogle } from "react-icons/fc";-import { FaGithub } from "react-icons/fa";+import { FaGithub, FaGitlab } from "react-icons/fa";import { SiOkta, SiAuth0, SiAmazoncognito } from "react-icons/si";import { TbBrandAzure, TbBrandOauth } from "react-icons/tb";import { signIn } from "next-auth/react";@@ -46,6 +46,7 @@ export type PageProps = {credentials: boolean;google: boolean;github: boolean;+ gitlab: boolean;okta: boolean;azureAd: boolean;auth0: boolean;@@ -73,6 +74,9 @@ export const getServerSideProps: GetServerSideProps<PageProps> = async () => {github:env.AUTH_GITHUB_CLIENT_ID !== undefined &&env.AUTH_GITHUB_CLIENT_SECRET !== undefined,+ gitlab:+ env.AUTH_GITLAB_CLIENT_ID !== undefined &&+ env.AUTH_GITLAB_CLIENT_SECRET !== undefined,okta:env.AUTH_OKTA_CLIENT_ID !== undefined &&env.AUTH_OKTA_CLIENT_SECRET !== undefined &&@@ -161,6 +165,16 @@ export function SSOButtons({Github</Button>)}+ {authProviders.gitlab && (+ <Button+ onClick={() => handleSignIn("gitlab")}+ variant="secondary"+ loading={providerSigningIn === "gitlab"}+ >+ <FaGitlab className="mr-3" size={18} />+ Gitlab+ </Button>+ )}{authProviders.azureAd && (<ButtononClick={() => handleSignIn("azure-ad")}diff --git a/web/src/server/auth.ts b/web/src/server/auth.tsindex e8b0a0e078..15bd2bc096 100644--- a/web/src/server/auth.ts+++ b/web/src/server/auth.ts@@ -17,6 +17,7 @@ import { type Adapter } from "next-auth/adapters";import CredentialsProvider from "next-auth/providers/credentials";import GoogleProvider, { type GoogleProfile } from "next-auth/providers/google";import GitHubProvider from "next-auth/providers/github";+import GitLabProvider from "next-auth/providers/gitlab";import OktaProvider from "next-auth/providers/okta";import EmailProvider from "next-auth/providers/email";import Auth0Provider from "next-auth/providers/auth0";@@ -226,6 +227,16 @@ if (env.AUTH_GITHUB_CLIENT_ID && env.AUTH_GITHUB_CLIENT_SECRET)}),);+if (env.AUTH_GITLAB_CLIENT_ID && env.AUTH_GITLAB_CLIENT_SECRET)+ staticProviders.push(+ GitLabProvider({+ clientId: env.AUTH_GITLAB_CLIENT_ID,+ clientSecret: env.AUTH_GITLAB_CLIENT_SECRET,+ allowDangerousEmailAccountLinking:+ env.AUTH_GITLAB_ALLOW_ACCOUNT_LINKING === "true",+ })+ );+if (env.AUTH_AZURE_AD_CLIENT_ID &&env.AUTH_AZURE_AD_CLIENT_SECRET &&