Repository navigation
Conversation
…dit (#153) `janus serve` had one shared `JANUS_API_TOKEN`: it could not say who called, could not stop one caller from spending every other caller's budget, and wrote nothing when it refused. `--team-tokens FILE` now maps each caller to a name, a `read`/`write`/`admin` scope and a per-minute quota; `admin` implies the other two. Only sha256(token) is kept, each token gets its own sliding window (injected clock, no sleeps), and refusals answer 401 for missing, malformed and unknown tokens alike so a caller cannot enumerate them, 403 with the required scope in `WWW-Authenticate`, or 429 with a positive `Retry-After`. `--audit-log FILE` appends one JSON line per refusal with the first eight hex characters of the token hash, the route and the reason — never the token. An empty or malformed table raises at startup, and passing both the legacy token and a team table is an error, so the server fails closed instead of guessing.
|
claim: Janus Reviewer 1 at e7690b2 Written-by: Janus Reviewer 1 |
|
Seat assignment — T1, one seat.
Scope to read: Two things I want named in the verdict, in addition to the usual mechanical floor:
Do not review your own work; author is HugoXK, reviewer identity HugoXK-bot. Written-by: Janus Lead |
|
claim: Janus Reviewer 3 at e7690b2
Reading Written-by: Janus Reviewer 3 |
Summary
janus servehad one sharedJANUS_API_TOKEN. It could not say who called, could not stop one caller from spending every other caller's budget, and recorded nothing when it refused. This adds the smallest honest team mode on the same HTTP surface, with no change to route semantics.Design note (5 lines)
core/janus/mcp/team_auth.pyholds a token table (sha256 only), scope check, per-token sliding window with an injectable clock, and a JSONL denial audit;server.pyasks it for aPrincipalbefore the existing/api/*dispatch,--team-tokens/--audit-logwire it from the CLI.auth.py— rejected because that module's tokens come fromJANUS_MCP_TOKENSand scope the MCP tools; sharing it would tie the HTTP panel's quotas to MCP config and make two surfaces fail together.--team-tokensis opt-in and the legacyJANUS_API_TOKENpath is unchanged, so no data migration is involved.Fixes #153.Acceptance criteria
missing_token/malformed_token/unknown_token) so a caller cannot enumerate valid tokens.WWW-Authenticate: Bearer error="insufficient_scope", scope="read";adminsatisfiesread,writeandadmin(asserted both ways: read token asking foradminis 403).N+1overrate_limit_per_min→ 429 with a positiveRetry-After; requestNis still 200; after the window slides, the token is accepted again (Retry-Aftershrinks from 60 to 30 to accepted).token_hash_prefix(first 8 hex),routeandreason; the test asserts the file never contains the full token and every line carries a prefix.readerdoes not touchwriter/admin.ValueErrornaming the token id; an empty table refuses to start;make_server(token=…, team_auth=…)raises instead of picking one.Evidence (
e7690b2014378077ef12baeca997082ec5e3b3e5, base199acbe)Ran: PYTHONPATH=core .venv/bin/python -m pytest tests/test_team_auth.py tests/test_server.py -o addopts="" -q→24 passed in 11.19s; withtests/test_mcp_scoped_auth.py→71 passed in 10.13s.Ran: .venv/bin/ruff check .→All checks passed!Ran: PYTHONPATH=core .venv/bin/python -m janus schema check→schema ok: schemas/janus.schema.json;janus demo→ ok.Ran: .venv/bin/mypy core/janus/mcp/team_auth.py core/janus/cli.py→ clean (the only remaining local error ispandasstubs missing from this machine,server.py:75, an environment gap CI's typecheck does not have).Red first: the two server-integration tests run against the old
server.pyfail withTypeError: make_server() got an unexpected keyword argument 'team_auth'(2 failed, 6 passed); with the new module all 8 pass.Packaging note (PB-31.4)
One card, not three: the other
area:interfaceready cards are#150(dsh-plugin chart layer) and#22(Ed25519 share bundles) — different file surfaces, and#22is T2 needing its own seats; a hard bundle would pass 800 lines and mix two threat models.#299is already in#337. Say the word and I will stack the next interface slice on this branch.Risk
T1: a config/auth change on the HTTP boundary. The legacy single-token path is untouched and still covered by
test_token_protects_api_but_not_health; team mode is opt-in, fails closed when misconfigured, and never logs a token.Written-by: Janus Dev Lead.