claude-os/mcp_server
Rosie Val 9298de1a49 Fix auth so it actually enforces, not just decorates
Two gaps found while wiring auth into the data routes:

1. mcp_server/auth.py: HTTPBearer() defaults to auto_error=True, which
   rejects any request with no Authorization header before
   get_current_user's own "auth not configured -> allow as guest"
   check ever runs. That meant turning on Depends(get_current_user)
   anywhere 401'd every request even with auth fully disabled.
   Switched to auto_error=False and handle the missing-credentials
   case explicitly inside get_current_user instead.

2. Frontend never actually sent the stored token on data requests.
   auth.tsx only attached it to its own /api/auth/me check; api.ts's
   fetch() calls (chat, stats, documents, upload, delete) and every
   axios call elsewhere in the app (projects, kanban, hooks) had no
   Authorization header at all. Added an authHeaders() helper in
   api.ts, and a single axios request interceptor in auth.tsx that
   attaches the token app-wide since every component imports the same
   default axios instance.

Known gap not addressed here: mcp_server/claude_code_mcp.py (the
code-forge stdio MCP server) calls the REST API with no token at all.
Harmless while auth is disabled (current state), but it will start
getting 401'd the moment CLAUDE_OS_EMAIL/PASSWORD are actually set -
needs a service-token bypass if that's ever turned on.
2026-08-22 15:46:45 -04:00
..
tools first commit 2025-10-22 13:29:28 -05:00
__init__.py first commit 2025-10-22 13:29:28 -05:00
auth.py Fix auth so it actually enforces, not just decorates 2026-08-22 15:46:45 -04:00
claude_code_mcp.py feat: Add cross-KB search, inline health checks, and simplify templates 2026-02-06 11:04:21 -06:00
server.py Require auth on all data API routes, not just /api/auth/me 2026-08-22 15:43:16 -04:00