mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-15 20:25:23 +02:00
refactor: replace BETTER_AUTH_SECRET with betterAuthSecret in forward-auth setup
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { createHmac } from "node:crypto";
|
import { createHmac } from "node:crypto";
|
||||||
import type { CreateServiceOptions } from "dockerode";
|
import type { CreateServiceOptions } from "dockerode";
|
||||||
|
import { betterAuthSecret } from "../lib/auth-secret";
|
||||||
import { getRemoteDocker } from "../utils/servers/remote-docker";
|
import { getRemoteDocker } from "../utils/servers/remote-docker";
|
||||||
|
|
||||||
export const FORWARD_AUTH_SERVICE_NAME = "dokploy-forward-auth";
|
export const FORWARD_AUTH_SERVICE_NAME = "dokploy-forward-auth";
|
||||||
@@ -37,13 +38,7 @@ export const forwardAuthCallbackUrl = (
|
|||||||
): string => `${https ? "https" : "http"}://${authDomain}/oauth2/callback`;
|
): string => `${https ? "https" : "http"}://${authDomain}/oauth2/callback`;
|
||||||
|
|
||||||
export const deriveCookieSecret = (salt: string): string => {
|
export const deriveCookieSecret = (salt: string): string => {
|
||||||
const rootSecret = process.env.BETTER_AUTH_SECRET;
|
return createHmac("sha256", betterAuthSecret)
|
||||||
if (!rootSecret) {
|
|
||||||
throw new Error(
|
|
||||||
"BETTER_AUTH_SECRET is required to derive the forward-auth cookie secret",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return createHmac("sha256", rootSecret)
|
|
||||||
.update(`forward-auth:${salt}`)
|
.update(`forward-auth:${salt}`)
|
||||||
.digest("base64");
|
.digest("base64");
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user