From 094273d8531aa0fc951d86621899368e95e6220f Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Mon, 2 Feb 2026 13:35:10 +0100 Subject: [PATCH] Updates --- apps/auth-server/index.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/auth-server/index.ts b/apps/auth-server/index.ts index e474ac4..805f148 100644 --- a/apps/auth-server/index.ts +++ b/apps/auth-server/index.ts @@ -8,6 +8,8 @@ type AdminPagesAuth = { url?: string; }; +const AuthExpiryTime = 1000 * 60 * 60; + const server = Bun.serve({ port: AuthServerPort, hostname: "0.0.0.0", @@ -17,8 +19,6 @@ const server = Bun.serve({ try { const reqURL = new URL(req.url); - console.log("reqURL", reqURL); - if (reqURL.pathname !== "/") { return new Response("Auth Success!", { status: 200, @@ -30,8 +30,6 @@ const server = Bun.serve({ const href = `https://${host}${query}`; const url = new URL(href); - console.log("url", url); - const key = url.searchParams.get("key"); const decryptedKey = JSON.parse( @@ -40,12 +38,20 @@ const server = Bun.serve({ const decrptedUrl = decryptedKey.url; - console.log("decrptedUrl", decrptedUrl); - if (!host || !decrptedUrl) { throw new Error(`Origin Not Found!`); } + if (decrptedUrl !== host) { + throw new Error(`Host Mismatch!`); + } + + const dateIssued = decryptedKey.date; + + if (Date.now() - dateIssued > AuthExpiryTime) { + throw new Error(`Key Expired!`); + } + return new Response("Auth Success!", { status: 200, });