MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / hasValidAdminApiKey

Function hasValidAdminApiKey

server/src/middleware/auth.ts:572–580  ·  view source on GitHub ↗

* Check if request has a valid static admin API key * Returns true if the Bearer token matches ADMIN_API_KEY

(req: Request)

Source from the content-addressed store, hash-verified

570 * Returns true if the Bearer token matches ADMIN_API_KEY
571 */
572function hasValidAdminApiKey(req: Request): boolean {
573 if (!ADMIN_API_KEY) return false;
574 const authHeader = req.headers.authorization;
575 if (!authHeader?.startsWith('Bearer ')) return false;
576 const token = authHeader.slice(7);
577 // Don't match WorkOS API keys - those are handled separately
578 if (isWorkOSApiKeyFormat(token)) return false;
579 return token === ADMIN_API_KEY;
580}
581
582/**
583 * Middleware to require authentication

Callers 1

requireAuthFunction · 0.85

Calls 1

isWorkOSApiKeyFormatFunction · 0.85

Tested by

no test coverage detected