The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Use request headers for SAML enforcement hostname
Kiran K87eea4ba11e5
diff --git a/apps/web/lib/auth/options.ts b/apps/web/lib/auth/options.tsindex 53896e27ea..8f2419bede 100644--- a/apps/web/lib/auth/options.ts+++ b/apps/web/lib/auth/options.ts@@ -17,6 +17,7 @@ import CredentialsProvider from "next-auth/providers/credentials";import EmailProvider from "next-auth/providers/email";import GithubProvider from "next-auth/providers/github";import GoogleProvider from "next-auth/providers/google";+import { headers } from "next/headers";import { createId } from "../api/create-id";import { qstash } from "../cron";import { isGenericEmail } from "../emails";@@ -591,13 +592,16 @@ export const authOptions: NextAuthOptions = {// Checks if SAML SSO is enforced for a given email domainexport const isSamlEnforcedForDomain = async (email: string) => {- const hostname = new URL(process.env.NEXTAUTH_URL as string).hostname;- if (!APP_HOSTNAMES.has(hostname)) {- return;- }-+ const headersList = headers();const emailDomain = email.split("@")[1];- if (!emailDomain || isGenericEmail(emailDomain)) {+ const hostname = headersList.get("host");++ if (+ !hostname ||+ !emailDomain ||+ !APP_HOSTNAMES.has(hostname) ||+ isGenericEmail(emailDomain)+ ) {return false;}