MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / loginRateLimitOk

Function loginRateLimitOk

telemetry-dashboard/src/index.ts:144–158  ·  view source on GitHub ↗

Best-effort brute-force cap on the shared password, keyed by client IP.

(env: Env, request: Request)

Source from the content-addressed store, hash-verified

142
143/** Best-effort brute-force cap on the shared password, keyed by client IP. */
144async function loginRateLimitOk(env: Env, request: Request): Promise<boolean> {
145 // Note for auditors: unlike the ingest worker — which never reads the client
146 // IP — this admin login does, purely as a rate-limit key. It is not stored,
147 // logged or forwarded anywhere.
148 const key = request.headers.get('cf-connecting-ip') ?? 'unknown';
149 try {
150 const { success } = await env.LOGIN_RATE_LIMITER.limit({ key });
151 return success;
152 } catch (err) {
153 // Fail open: a rate-limiter outage must not lock the maintainer out, and
154 // the password is still required either way.
155 console.error(JSON.stringify({ msg: 'login rate limiter unavailable', err: String(err) }));
156 return true;
157 }
158}
159
160async function handleLoginPage(env: Env, request: Request, url: URL): Promise<Response> {
161 const next = safeNextPath(url.searchParams.get('next'));

Callers 1

handleLoginSubmitFunction · 0.85

Calls 2

errorMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected