feat: per-user access keys with individual revocation#5
Open
znaniye wants to merge 1 commit into
Open
Conversation
Add authorizedKeys: a named allowlist of static access keys, one per person (sk-proxy-… tokens), accepted alongside the legacy shared proxySecret. Each key is granted and revoked individually via `cc-router keys add/list/revoke`. Since Claude Code only sends a static ANTHROPIC_AUTH_TOKEN (it can't present a client certificate), per-user keys authorize specific people without an nginx/mTLS layer in front. Auth is a structured, testable outcome so connection failures are diagnosable from the server log without ever leaking the secret. Each rejection says exactly what happened — no credentials, malformed header, unknown token, or a correct-but-disabled key — with the carrying header, token length, and a short sha256 fingerprint that correlates with the fingerprint shown by `cc-router keys list`. Accepted requests log once per key and are attributed to their owner in the dashboard. - config: AuthorizedKey type + add/list/revoke helpers, generateUserKey - proxy/auth: buildCredentials + extractPresented + authenticate + describeAuthFailure + fingerprint (all pure, constant-time compare) - proxy/server: multi-credential auth middleware, _authUser attribution, clientIpOf (X-Forwarded-For aware), accept/reject server logging - proxy/logger: logAuthReject/logAuthAccept, [user] on logRoute - stats: per-user request counters exposed as usageByUser on /health - ui: [user] label on activity rows + per-key request tally - cli: cc-router keys command group (list shows fingerprints) - tests: 18 cases covering config round-trip, extraction, auth outcomes, fingerprinting, and secret-safe failure messages - docs: README auth section, security note, CLI reference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add authorizedKeys: a named allowlist of static access keys, one per person (sk-proxy-… tokens), accepted alongside the shared proxySecret. Each key is granted and revoked individually via
cc-router keys add/list/revoke. Since Claude Code only sends a static ANTHROPIC_AUTH_TOKEN (it can't present a client certificate), per-user keys authorize specific people without an nginx/mTLS layer in front.Auth is a structured, testable outcome so connection failures are diagnosable from the server log without ever leaking the secret. Each rejection says exactly what happened — no credentials, malformed header, unknown token, or a correct-but-disabled key — with the carrying header, token length, and a short sha256 fingerprint that correlates with the fingerprint shown by
cc-router keys list. Accepted requests log once per key and are attributed to their owner in the dashboard.What this PR does
Type of change
Testing
npm run buildpassesnpm testpassesRelated issues