* Check if request has a valid static admin API key * Returns true if the Bearer token matches ADMIN_API_KEY
(req: Request)
| 570 | * Returns true if the Bearer token matches ADMIN_API_KEY |
| 571 | */ |
| 572 | function 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 |
no test coverage detected