chmonitor has two independent auth layers that work together on every /api/v1/* route:
- Auth provider — one of
none,clerk, orproxy. Controls whether browser sessions are authenticated. Set withCHM_AUTH_PROVIDER(server) andVITE_AUTH_PROVIDER(client, build-time inlined). Legacy Next.js app usesNEXT_PUBLIC_AUTH_PROVIDERinstead ofVITE_AUTH_PROVIDER. - API key layer — always active when
CHM_API_KEY_SECRETis set. Authenticates programmatic clients (MCP, scripts, CI) with signedchm_Bearer tokens, independent of the provider.
A request is allowed when either layer accepts it. The only fully public setup is CHM_AUTH_PROVIDER=none with no CHM_API_KEY_SECRET.
Summary
| Method | Who reads it | Browser / proxy auth | curl / MCP auth |
|---|---|---|---|
Public (none) | — | open | none needed |
| API key | Provider-agnostic; active when CHM_API_KEY_SECRET set | — | Authorization: Bearer chm_… |
| Clerk | clerk provider | Clerk __session cookie | Clerk token or chm_ key |
| Clerk OAuth (MCP only) | MCP server | — | OAuth bearer token |
| Proxy → Cloudflare Access | proxy provider | Cf-Access-Jwt-Assertion JWT | — |
| Proxy → trusted header | proxy provider | X-Forwarded-User + shared secret | shared secret header |
How enforcement decides
For each /api/v1/* request, in order:
- If
CHM_AUTH_PROVIDER=noneandCHM_API_KEY_SECRETis not set → allow (public). - The key-issuance route
/api/v1/auth/api-keyis exempt (it has its own auth). - A valid
chm_Bearer token → allow. - The active provider’s check runs; if it authenticates → allow.
- Otherwise →
401 { "error": "Authentication required" }.
All paths fail closed: a missing config or verification error resolves to “not authenticated”.
Which one should I use?
| Situation | Recommended setup |
|---|---|
| Local dev or internal network, no login needed | Public (none) — default |
| Hosted dashboard with user accounts and sign-in | Clerk |
| Behind Cloudflare Access or nginx/SSO | Proxy (cloudflare-access or trusted-header) |
| MCP clients, scripts, CI pipelines | API key (CHM_API_KEY_SECRET) — add alongside any provider |
Provider pages
- Public / no auth — default open dashboard
- API keys —
chm_Bearer tokens for programmatic access - Clerk — browser sign-in with Clerk sessions
- Cloudflare Access — reverse proxy JWT verification
- Trusted header — reverse proxy with shared secret