GeezerVison is showing github.com — mcpx: optional bearer token for /v1 and /mcp · Issue #1975 · developing-today/code
mcpx: optional bearer token for /v1 and /mcp #1975DescriptionRelocated from dezren39/darwin-nix#338 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue references inside it are historical (dezren39/nix numbering).
Today anything that can reach the daemon's socket or loopback port is trusted; the Origin/Host check stops browsers, not callers.
Optional, off unless set: a setting (e.g. transport.bearerToken, from env so it need not live in a config file) that, when set, makes every /v1 and /mcp request carry Authorization: Bearer <token> or get 401. Unset keeps today's behaviour. Reject tokens shorter than 32 characters, as codex-connectors-mcp does.
The CLI, plugin and scripts read the same setting so they keep working. A first, cheap step toward #253 (authorization) and #300 (the permissive interface that authorizes everyone); principals per surface are #298.
Reference: https://github.com/wileai/codex-connectors-mcp (CODEX_CONNECTORS_HTTP_TOKEN).
Acceptance criteria
- With
transport.bearerToken set (sourced from env), every /v1 and /mcp request without a matching Authorization: Bearer <token> gets 401; with the token it succeeds.
- With the setting unset, behaviour is byte-for-byte today's (no auth check).
- Tokens shorter than 32 characters are rejected at startup/config load with a clear error.
- The CLI, plugin, and scripts read the same setting and keep working when it is set.
Activitydeveloping-today commented on Oct 28, 2026 dezren39 commented on Oct 28, 2026 History carried over from dezren39/darwin-nix#338 (verbatim, oldest first):
@dezren39 · 2026-10-27T11:47:10Z
Intake review
Fleet monitor intake enrichment, 2026-10-27.
Liveness: still live — no merged PR implements the optional bearer token. Related: #253 (OAuth authorization), #298 (principal per surface), #300 (permissive auth interface).
Notes: Deliberately a first, cheap step — a shared secret, not principals. Suggested approach: single middleware check on both surfaces, one shared token-reading helper so CLI/plugin/scripts cannot drift.
Risks: token comparison should be constant-time; do not log the token; docs must state this is not a substitute for #253/#298.
dezren39 commented on Oct 30, 2026 🤖 Agent note · done
- Agent: queue worker (repo-worker-code), Lane B shift
- Session / ID: queue task 3271
- Found via: queue claim (resume — implementation + PR mcpx: optional bearer-token auth for /v1 and /mcp (#1975) #2711 already existed from a prior lane)
- Result: PR mcpx: optional bearer-token auth for /v1 and /mcp (#1975) #2711 MERGED (merge commit 85960a6, head 75cf534 after merging current main and chaining the bearer wrapper with main's authorize wrapper from mcpx: thin provider layer core — internal/model, model.* settings, intent routing (#1925 slice 1) #2592). Bearer-token auth for /v1 and /mcp is live on main: transport.bearerToken (env-sourced, min 32), constant-time check, unset = unchanged.
- This shift added: Codex rounds on the resumed PR dispositioned one by one — scriptEnv token propagation to daemon-hosted scripts + consumer recipes (4b73ecb), per-record daemon credential resolution for stop --all / daemons (d02a018), chain-based resolution preserving inherited tokens (663dbf8); all 8 Codex threads replied and resolved. Laptop verification: full internal/daemon, internal/cli, internal/execsvc suites pass; bearer/dashboard/proxy tests pass post-merge with main.
- Follow-ups staying on this issue: (1) dashboard browser credential bootstrap (fail-closed 401 until designed; see the in-progress note above), (2) replace the settings EffectExemptions entry for transport.bearerToken with an e2e probe that starts a token’d daemon and drives a caller against it (noted on PR mcpx: optional bearer-token auth for /v1 and /mcp (#1975) #2711).
dezren39 commented on Nov 3, 2026
🤖 Agent note · triaged → already implemented and on main; closing COMPLETED (the merge never auto-closed this issue)
- Agent: queue worker
repo-worker-code, OpenChamber scheduled lane (queue task 7806, coverage-pass triage)
- Landed in: PR mcpx: optional bearer-token auth for /v1 and /mcp (#1975) #2711 — merged 2026-10-30T20:22:46Z as
85960a654807aecb42c431868f8baac0b4aa2e0b (branch queue/3271-1975-bearer-token), confirmed an ancestor of origin/main d3476bce7. Prior task 3271 logged the merge in its note; the issue itself stayed open because the PR carried no closing keyword.
Acceptance criteria, verified at current main
- ✅ Bearer enforced on every
/v1 and /mcp request when set — internal/daemon/bearer.go:59 requireBearer wraps the whole HTTP surface, chained in both handler constructions (internal/daemon/server.go:457, :531); missing/mismatched credential → 401 with a message naming transport.bearerToken, constant-time compare.
- ✅ Unset means today's behaviour — the wrapper is a pass-through when no token is configured (
bearer.go reads transport.bearerToken, empty = no check).
- ✅ Tokens under 32 characters rejected at config load with a clear error —
MinBearerTokenLength check at bearer.go:50; internal/daemon/bearer_test.go:84 asserts the error names the setting and the 32-character minimum.
- ✅ CLI, plugin and scripts read the same setting —
internal/cli/client.go:134-193 (targetBearerToken, own-daemon and target-daemon resolution) plus docs/environment.md:112 for MCPX_TRANSPORT_BEARER_TOKEN handed to daemon-hosted scripts; internal/cli/bearer_test.go covers the eight previously-unauthorized CLI request paths and the target-daemon resolution P2.
- Settings registry entry documented:
docs/configuration.md:1070 (transport.bearerToken / --transport-bearer-token / MCPX_TRANSPORT_BEARER_TOKEN).
Verification run for this triage (2026-11-03)
cd pkgs/mcpx && go test ./internal/daemon/ ./internal/cli/ -run Bearer -count=1 → ok / ok; the tree tested has zero diff against origin/main d3476bce7 in internal/daemon/bearer.go, internal/daemon/server.go and internal/cli.
- Issue labels were already free of queue state; nothing in flight, no open PR, no competing branch.
Scope note: this closes the optional bearer token step only. #253 (authorization), #298 (principals per surface) and #300 (permissive auth interface) remain the follow-on work and are untouched. dezren39 commented on Nov 3, 2026 agent-note:v1
state: triaged (coverage pass)
Coverage pass 2026-11-03: reviewed in the fleet-wide per-issue pass (drift / overlap / already-handled / stale / blockers / ordering). Verdict: still live; queued in repo-health-code-pilot as triage at priority 40 (priority/normal). If this is already handled at current main, the triage closes it with evidence; if it needs splitting, the triage files the split.
Found via: coverage pass 2026-11-03
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|