mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-23 00:53:38 +02:00
Address Greptile auth cookie feedback
This commit is contained in:
1 parent
4753e380e1
commit
dccf3372f7
2 files changed
+5
-4
No files matched your search
@@ -112,13 +112,14 @@ describe("Better Auth cookie scoping", () => {
|
||||
} as Parameters<typeof shouldDisableSecureAuthCookies>[0])).toBe(false);
|
||||
});
|
||||
|
||||
it("lets PAPERCLIP_PUBLIC_URL override the auth base URL for cookie security", () => {
|
||||
process.env.PAPERCLIP_PUBLIC_URL = "http://paperclip-dev:46259";
|
||||
it("uses the caller-resolved public URL for cookie security", () => {
|
||||
process.env.PAPERCLIP_PUBLIC_URL = "https://ignored.example.test";
|
||||
|
||||
expect(shouldDisableSecureAuthCookies({
|
||||
deploymentMode: "authenticated",
|
||||
authBaseUrlMode: "explicit",
|
||||
authPublicBaseUrl: "https://paperclip.example.test",
|
||||
publicUrl: "http://paperclip-dev:46259",
|
||||
} as Parameters<typeof shouldDisableSecureAuthCookies>[0])).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ export function shouldDisableSecureAuthCookies(input: {
|
||||
}): boolean {
|
||||
const publicUrl = (
|
||||
input.publicUrl?.trim() ||
|
||||
process.env.PAPERCLIP_PUBLIC_URL?.trim() ||
|
||||
(input.authBaseUrlMode === "explicit" ? input.authPublicBaseUrl?.trim() : "")
|
||||
);
|
||||
if (publicUrl) return publicUrl.startsWith("http://");
|
||||
@@ -115,6 +114,7 @@ export function deriveAuthTrustedOrigins(config: Config, opts?: { listenPort?: n
|
||||
|
||||
export function createBetterAuthInstance(db: Db, config: Config, trustedOrigins: string[]): BetterAuthInstance {
|
||||
const baseUrl = config.authBaseUrlMode === "explicit" ? config.authPublicBaseUrl : undefined;
|
||||
const publicUrl = process.env.PAPERCLIP_PUBLIC_URL?.trim() || baseUrl;
|
||||
const secret = process.env.BETTER_AUTH_SECRET ?? process.env.PAPERCLIP_AGENT_JWT_SECRET;
|
||||
if (!secret) {
|
||||
throw new Error(
|
||||
@@ -127,7 +127,7 @@ export function createBetterAuthInstance(db: Db, config: Config, trustedOrigins:
|
||||
deploymentExposure: config.deploymentExposure,
|
||||
authBaseUrlMode: config.authBaseUrlMode,
|
||||
authPublicBaseUrl: config.authPublicBaseUrl,
|
||||
publicUrl: process.env.PAPERCLIP_PUBLIC_URL ?? baseUrl,
|
||||
publicUrl,
|
||||
});
|
||||
|
||||
const authConfig = {
|
||||
|
||||
Reference in new issue
Block a user