Skip to content

Send the calling role to services that ask for it: forward_role (150) - #151

Merged
jerryfane merged 1 commit into
mainfrom
feat/role-header
Nov 15, 2026
Merged

jerryfane merged 1 commit into
mainfrom
feat/role-header

Conversation

@jerryfane

Copy link
Copy Markdown
Contributor

Closes 150. Jarvis 488215: macserve cannot tell which agent cancels jobs: through the dev2306 relay every caller reaches it from the Studio with the owner's token.

Change

  • policy.Service.ForwardRole ("forward_role": true): the proxy sets X-Keyring-Role: <role> on the upstream request.
  • outboundHeader drops a caller-sent X-Keyring-Role on every call (any service), so the header cannot be forged through the keyring; a service without the flag never receives one.
  • Refused (validation) on services that forward nothing: signing-only, gcloud-login, egress-proxy.
  • Dashboard: settable through pasted settings on connect and on the service edit page; a plain form edit keeps it; the service page shows "Agent name: sent as X-Keyring-Role"; the edit audit lists forward_role when it changes.
  • README section.

Evidence

  • TestForwardRoleNamesTheCallerAndCannotBeForged: caller sends x-keyring-role: owner; upstream sees exactly [phobos]; without the flag upstream sees none; minisign-sign/egress-proxy with the flag fail validation.
  • TestForwardRoleSetByPasteKeptByFormEdit: paste sets it, audit names it, page shows it, form edit keeps it.
  • Full race suite green (local go1.26.11; CI uses go.mod 1.24).

A service with "forward_role": true gets X-Keyring-Role: <role> on every
call. A caller-sent X-Keyring-Role is dropped on every call, so it cannot be
forged through the keyring. Off by default; refused on services that forward
nothing. Set by access.json or pasted settings (connect, edit); a form edit
keeps it; the service page shows it and the edit audit names it.
@jerryfane

Copy link
Copy Markdown
Contributor Author

test-check prove: inconclusive for both new tests (they use the new ForwardRole field, so the old code does not compile with them; the other two names listed are untouched tests in edited files). Manual mutants at 5670b33, each restored after: (1) drop out.Del(policy.RoleHeader) → TestForwardRoleNamesTheCallerAndCannotBeForged FAILS (forged header reaches a service without the flag); (2) drop header.Set(policy.RoleHeader, roleName) → same test FAILS; (3) edit paste ignores forward_role → TestForwardRoleSetByPasteKeptByFormEdit FAILS. All pass unmutated.

@jerryfane
jerryfane merged commit 8d10311 into main Nov 15, 2026
3 checks passed
@jerryfane
jerryfane deleted the feat/role-header branch November 15, 2026 17:13
@jerryfane

Copy link
Copy Markdown
Contributor Author

Reviewer: adspower-fleet-review
Runtime: omp
Job: local-review-review-router-18e846ec1936fa77-1

Decision: approved
Summary: Reviewed the complete diff from da03961 to exact head 5670b33. No correctness or introduced design findings. No prior findings in frozen verdicts or GitHub reviews/comments. Local checks and wire-level smoke passed. Sandbox-denied C headers prevented local CGO/race checks; successful exact-head CI verified corresponding coverage. No repository files changed.

Tests Run

  • CGO_ENABLED=0 go build ./... -> passed
  • CGO_ENABLED=0 go vet ./... -> passed
  • CGO_ENABLED=0 go test -count=1 -v ./internal/server ./internal/policy ./internal/dashboard -run 'ForwardRole|FixedHeaders|ExtraHeader|ProxyAddsKey|HeaderAndQueryAuth|Refusals|SwapApplies|ServiceEdit|Connect' -> passed
  • CGO_ENABLED=0 go test -count=1 ./internal/server ./internal/policy ./internal/dashboard -> all packages passed
  • CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build ./... -> passed on retry after initial command deadline
  • CGO_ENABLED=0 go build -o "$smoke_dir/keyring" ./cmd/keyring; KEYRING_SMOKE_BIN="$smoke_dir/keyring" python3 - <<'PY' [inline isolated HTTP harness] -> passed: two authenticated roles, bearer/header/query authentication, duplicate mixed-case forged headers, Connection nomination, opt-out, credential preservation, invalid-token rejection
  • go build ./...; go vet ./...; go test -count=1 ./internal/server ./internal/policy ./internal/dashboard -> blocked by sandbox denial of /usr/include/stdc-predef.h
  • CI-verified: go build ./... -> success; run 43739184193 job 132888356518
  • CI-verified: go vet ./... -> success; run 43739184193 job 132888356518
  • CI-verified: go test -race ./... -count=1 -> success; run 43739184193 job 132888356518

Raw runtime output was retained in local Gitmoot state and is not posted here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant