anthropic auth proxy for multi-user claude code

Local HTTP proxy on 127.0.0.1:5051 intercepts Claude Code API requests
from sandboxed member users, injects the real OAuth token server-side,
and forwards to Anthropic. Users only see a proxy secret, never the
real credentials.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 03:40:14 +00:00
co-authored by Claude Opus 4.6
parent e966a71180
commit 038fd16fb2
4 changed files with 116 additions and 9 deletions
@@ -56,9 +56,11 @@ claudeCodeRouter.get('/auth', async (ctx) => {
const proc = Bun.spawn(['claude', 'auth', 'status'], { stdout: 'pipe', stderr: 'pipe' });
const output = await new Response(proc.stdout).text();
await proc.exited;
if (proc.exitCode !== 0) return ctx.json({ authenticated: false });
const status = JSON.parse(output.trim());
return ctx.json({ authenticated: status.loggedIn ?? false, ...status });
if (proc.exitCode === 0) {
const status = JSON.parse(output.trim());
if (status.loggedIn) return ctx.json({ authenticated: true, ...status });
}
return ctx.json({ authenticated: false });
} catch {
return ctx.json({ authenticated: false });
}