MCPcopy Create free account
hub / github.com/codeaashu/claude-code / validateAuthToken

Function validateAuthToken

src/server/web/auth.ts:7–16  ·  view source on GitHub ↗
(req: IncomingMessage)

Source from the content-addressed store, hash-verified

5 * If AUTH_TOKEN is not set, all connections are allowed.
6 */
7export function validateAuthToken(req: IncomingMessage): boolean {
8 const authToken = process.env.AUTH_TOKEN;
9 if (!authToken) {
10 return true;
11 }
12
13 const url = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
14 const token = url.searchParams.get("token");
15 return token === authToken;
16}
17
18/**
19 * Simple per-IP rate limiter for new connections.

Callers 1

auth.test.tsFile · 0.85

Calls 1

getMethod · 0.65

Tested by

no test coverage detected