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

Function isSameOriginPost

telemetry-dashboard/src/auth.ts:165–179  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

163 * cross-site POST; this is the belt to that pair of braces.
164 */
165export function isSameOriginPost(request: Request): boolean {
166 const origin = request.headers.get('origin');
167 if (!origin) return true; // Absent on some legitimate non-browser clients (curl).
168 // "null" is what Chromium sends on a SAME-origin form submit when the page
169 // carries our own `Referrer-Policy: no-referrer` header — an unattributed
170 // origin, not a foreign one. Treat it like an absent header: rejecting it
171 // locks every Chromium user out of the login form, while an attacker who
172 // knows the password never needed a browser in the first place.
173 if (origin === 'null') return true;
174 try {
175 return new URL(origin).host === new URL(request.url).host;
176 } catch {
177 return false;
178 }
179}

Callers 2

handleLoginSubmitFunction · 0.90
fetchFunction · 0.90

Calls 1

getMethod · 0.65

Tested by

no test coverage detected