Skip to content

Commit c1c887d

Browse files
committed
fix: update deriveCookieSecret to meet oauth2-proxy requirements
1 parent 0f77c40 commit c1c887d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎packages/server/src/setup/forward-auth-setup.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ export const forwardAuthCallbackUrl = (
3838
): string => `${https ? "https" : "http"}://${authDomain}/oauth2/callback`;
3939

4040
export const deriveCookieSecret = (salt: string): string => {
41+
// oauth2-proxy requires cookie_secret to be exactly 16, 24, or 32 bytes.
42+
// Take the first 32 hex chars (= 16 bytes) to satisfy that constraint.
4143
return createHmac("sha256", betterAuthSecret)
4244
.update(`forward-auth:${salt}`)
43-
.digest("base64");
45+
.digest("hex")
46+
.slice(0, 32);
4447
};
4548

4649
export const buildForwardAuthEnv = (

0 commit comments

Comments
 (0)