MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / isAuthorized

Function isAuthorized

projects/runtime-node/src/server.ts:62–66  ·  view source on GitHub ↗
(request: http.IncomingMessage, options: Required<Pick<RuntimeNodeHttpServerOptions, "allowUnauthenticatedLoopback">> & Pick<RuntimeNodeHttpServerOptions, "host" | "token">)

Source from the content-addressed store, hash-verified

60}
61
62function isAuthorized(request: http.IncomingMessage, options: Required<Pick<RuntimeNodeHttpServerOptions, "allowUnauthenticatedLoopback">> & Pick<RuntimeNodeHttpServerOptions, "host" | "token">): boolean {
63 const token = tokenFromRequest(request)
64 if (options.token) return token === options.token
65 return options.allowUnauthenticatedLoopback && isLoopbackHost(options.host ?? "127.0.0.1")
66}
67
68function attachSocket(runtime: RuntimeServer, socket: WebSocket, request: http.IncomingMessage, options: RuntimeNodeHttpServerOptions): void {
69 const connectionId = `node:${randomUUID()}`

Callers 1

serveRuntimeNodeHttpFunction · 0.85

Calls 2

tokenFromRequestFunction · 0.85
isLoopbackHostFunction · 0.85

Tested by

no test coverage detected