MCPcopy Index your code
hub / github.com/simstudioai/sim / withAdminAuth

Function withAdminAuth

apps/sim/app/api/v1/admin/middleware.ts:16–29  ·  view source on GitHub ↗
(handler: AdminRouteHandler)

Source from the content-addressed store, hash-verified

14 * Returns early with an error response if authentication fails.
15 */
16export function withAdminAuth(handler: AdminRouteHandler): AdminRouteHandler {
17 return async (request: NextRequest) => {
18 const auth = authenticateAdminRequest(request)
19
20 if (!auth.authenticated) {
21 if (auth.notConfigured) {
22 return notConfiguredResponse()
23 }
24 return unauthorizedResponse(auth.error)
25 }
26
27 return handler(request)
28 }
29}
30
31/**
32 * Wrap a route handler with params with admin authentication.

Callers 12

route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 4

authenticateAdminRequestFunction · 0.90
notConfiguredResponseFunction · 0.90
unauthorizedResponseFunction · 0.90
handlerFunction · 0.50

Tested by

no test coverage detected