diff --git a/packages/server/src/setup/forward-auth-setup.ts b/packages/server/src/setup/forward-auth-setup.ts index d51601875..44ef3008c 100644 --- a/packages/server/src/setup/forward-auth-setup.ts +++ b/packages/server/src/setup/forward-auth-setup.ts @@ -1,5 +1,6 @@ import { createHmac } from "node:crypto"; import type { CreateServiceOptions } from "dockerode"; +import { betterAuthSecret } from "../lib/auth-secret"; import { getRemoteDocker } from "../utils/servers/remote-docker"; export const FORWARD_AUTH_SERVICE_NAME = "dokploy-forward-auth"; @@ -37,13 +38,7 @@ export const forwardAuthCallbackUrl = ( ): string => `${https ? "https" : "http"}://${authDomain}/oauth2/callback`; export const deriveCookieSecret = (salt: string): string => { - const rootSecret = process.env.BETTER_AUTH_SECRET; - if (!rootSecret) { - throw new Error( - "BETTER_AUTH_SECRET is required to derive the forward-auth cookie secret", - ); - } - return createHmac("sha256", rootSecret) + return createHmac("sha256", betterAuthSecret) .update(`forward-auth:${salt}`) .digest("base64"); };