MCPcopy
hub / github.com/codeaashu/claude-code / requireAuth

Method requireAuth

src/server/web/auth/apikey-auth.ts:109–122  ·  view source on GitHub ↗
(req: Request, res: Response, next: NextFunction)

Source from the content-addressed store, hash-verified

107 }
108
109 requireAuth(req: Request, res: Response, next: NextFunction): void {
110 const user = this.authenticate(req as unknown as IncomingMessage);
111 if (!user) {
112 const accept = req.headers["accept"] ?? "";
113 if (accept.includes("application/json")) {
114 res.status(401).json({ error: "Unauthorized" });
115 } else {
116 res.redirect(`/auth/login?next=${encodeURIComponent(req.originalUrl)}`);
117 }
118 return;
119 }
120 (req as AuthenticatedRequest).user = user;
121 next();
122 }
123
124 // ── Internals ─────────────────────────────────────────────────────────────
125

Callers

nothing calls this directly

Calls 3

authenticateMethod · 0.95
nextFunction · 0.85
statusMethod · 0.80

Tested by

no test coverage detected