huge optimizations

This commit is contained in:
KingKDot
2026-06-08 22:33:34 -05:00
parent 9a1fc96e2b
commit d6ad2cadea
21 changed files with 649 additions and 72 deletions
+16 -9
View File
@@ -1,6 +1,10 @@
import { logger } from "../logger";
import { timingSafeEqual } from "crypto";
let warnedDisableAuthIgnored = false;
let loggedAuthDisabledByEnv = false;
let loggedAuthDisabledNoToken = false;
function safeCompare(a: string, b: string): boolean {
const bufA = Buffer.from(a);
const bufB = Buffer.from(b);
@@ -19,16 +23,25 @@ export function isAuthorizedAgentRequest(
if (disableAuth) {
const nodeEnv = String(process.env.NODE_ENV || "development").toLowerCase();
if (nodeEnv === "production") {
logger.warn("[auth] OVERLORD_DISABLE_AGENT_AUTH is ignored in production mode");
if (!warnedDisableAuthIgnored) {
warnedDisableAuthIgnored = true;
logger.warn("[auth] OVERLORD_DISABLE_AGENT_AUTH is ignored in production mode");
}
} else {
logger.info("[auth] Agent auth explicitly disabled by OVERLORD_DISABLE_AGENT_AUTH=true (non-production mode)");
if (!loggedAuthDisabledByEnv) {
loggedAuthDisabledByEnv = true;
logger.info("[auth] Agent auth explicitly disabled by OVERLORD_DISABLE_AGENT_AUTH=true (non-production mode)");
}
return true;
}
}
const token = agentToken?.trim();
if (!token) {
logger.info("[auth] Agent auth disabled");
if (!loggedAuthDisabledNoToken) {
loggedAuthDisabledNoToken = true;
logger.info("[auth] Agent auth disabled");
}
return true;
}
@@ -38,11 +51,5 @@ export function isAuthorizedAgentRequest(
(headerToken !== null && safeCompare(headerToken, token)) ||
(queryToken !== null && safeCompare(queryToken, token));
if (!isAuthed) {
logger.info("[auth] Agent auth failed");
} else {
logger.info("[auth] Agent authenticated successfully");
}
return isAuthed;
}