Skip to content

feat(mediator): sign each kind of mediator call with its own secret - #58

Merged
widrss merged 2 commits into
mainfrom
feat/per-purpose-secrets
Nov 18, 2026
Merged

widrss merged 2 commits into
mainfrom
feat/per-purpose-secrets

Conversation

@widrss

@widrss widrss commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Problem

The backend signs every call to the mediator with MEDIATOR_WEBHOOK_SECRET, the same secret the exchange uses for its webhooks. The mediator is gaining optional per-purpose secrets (a2a-settlement/a2a-settlement-mediator#15); this is the matching client change.

Change

Three optional settings in Settings, each defaulting to empty and matching the mediator's setting of the same name:

Setting Signs
MEDIATOR_OPERATOR_SECRET operator-route calls: /mediate/{id}, /audits/{id} (v2= signature)
MEDIATOR_VERIFY_PATCH_SECRET POST /api/v1/verify-patch
MEDIATOR_RECEIPTS_SECRET POST /api/v1/receipts

mediator.signing_secret(purpose) returns the purpose's own secret when it is set and MEDIATOR_WEBHOOK_SECRET otherwise. _operator_headers and verify_patch use it. With the new settings empty, every call is signed exactly as before; the signature formats do not change.

No code in this repository issues receipts. MEDIATOR_RECEIPTS_SECRET and signing_secret("receipts") are there so a receipt client resolves its secret the same way. Until such a client uses it, do not set MEDIATOR_RECEIPTS_SECRET on the mediator for a caller that still signs with the webhook secret.

Unchanged edge cases: operator calls are still sent unsigned when no secret resolves (local development), and verify_patch still raises MEDIATOR_WEBHOOK_SECRET not configured when none resolves.

Fix-verifier preflight

_check_mediator required MEDIATOR_WEBHOOK_SECRET. It still passes when that is set. When it is empty it now also passes if MEDIATOR_VERIFY_PATCH_SECRET and MEDIATOR_RECEIPTS_SECRET are both set, so a backend that has moved to per-purpose secrets no longer has to hold the exchange's webhook secret. With one of the two missing, the error names it. With all three empty the error text is the same as before.

Rollout

Set the per-purpose secrets on the mediator first, with its transition setting on, then here. The steps are in the mediator's SECURITY.md.

Docs

.env.example, and the settings table and mediator-client paragraph in docs/cyber/legal-review-packet.md.

Tests

  • backend/tests/test_mediator_purpose_secrets.py: defaults; fallback and precedence per purpose; operator calls and verify-patch signed with their own secret and not with any other; behaviour with no webhook secret; no secret value on the wire.
  • backend/tests/test_fix_verifier_preflight.py: the new preflight cases.
  • Existing signing tests, including the known-answer vectors shared with the mediator, pass unchanged.

Backend suite: 2132 passed locally.

🤖 Generated with Claude Code

widrss and others added 2 commits November 17, 2026 21:55
Add optional MEDIATOR_OPERATOR_SECRET, MEDIATOR_VERIFY_PATCH_SECRET and
MEDIATOR_RECEIPTS_SECRET, matching the mediator's settings of the same
names. Operator-route calls and verify-patch are signed with their own
secret when it is set and with MEDIATOR_WEBHOOK_SECRET otherwise, so
nothing changes while the new settings are empty. Signature formats are
unchanged.

No code in this repository issues receipts; signing_secret("receipts")
resolves that secret the same way for a receipt client.

The fix-verifier preflight accepts the verify-patch and receipts secrets
together in place of MEDIATOR_WEBHOOK_SECRET, so the backend no longer has
to hold the exchange's webhook secret.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@widrss
widrss merged commit 7481491 into main Nov 18, 2026
1 check passed
@widrss
widrss deleted the feat/per-purpose-secrets branch November 18, 2026 03:02
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