ABACUS_API_KEY was ONE shared ingress secret for the whole deployment: any caller holding it could set X-Abacus-Agent to a DIFFERENT configured agent's id and spend from that agent's treasury/allowance under that agent's own per_request_max_micros (handler.rs run_flow, admin.rs::own_budget), or read its budget policy/live allowance headroom via GET /v1/budget — isolation only existed between the deployment and the outside world, never between agents. require_api_key now recomputes hex(HMAC-SHA256(ABACUS_API_KEY, agent_id)) for the X-Abacus-Agent the caller claims and compares it, constant-time, to the presented X-API-Key. The operator keeps ABACUS_API_KEY to itself and issues each agent only its own derived key, so an agent that knows only its key cannot derive (or forge) another agent's — HMAC preimage resistance — closing the cross-agent impersonation hole at the auth layer, before LocalStore's or PostgresProductStore's resolve() ever runs its bare agent_id lookup. Verified against the real build_router (not a stub): a throwaway example wired FakeBudgetRepo with two agents and proved agent A's derived key is rejected (401) when claiming to be agent B, the raw master key alone is rejected (401) on agent-scoped routes, and A's own key + own id still works (200) — then the example was deleted before this commit per no-test-files. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
47 lines
1.4 KiB
TOML
47 lines
1.4 KiB
TOML
[package]
|
|
name = "abacus-proxy"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
|
|
# The axum/tokio reverse-proxy SERVER — the enforcement point. It resolves the
|
|
# agent identity, prices the MAX possible cost, opens a Mint hold (direct or
|
|
# allowance-backed) as the reserve gate, forwards the request verbatim to the real
|
|
# provider, then captures the EXACT actual on success / releases on failure
|
|
# (HoldGuard RAII, ADR-0002 success-only), recording a Mint receipt as the
|
|
# system-of-record. Wires the REAL abacus-mint-client + abacus-upstream in
|
|
# main.rs; tests inject the abacus-testkit fakes.
|
|
[[bin]]
|
|
name = "abacus-proxy"
|
|
path = "src/main.rs"
|
|
|
|
[lib]
|
|
name = "abacus_proxy"
|
|
path = "src/lib.rs"
|
|
|
|
[dependencies]
|
|
abacus-core = { workspace = true }
|
|
abacus-mint-client = { workspace = true }
|
|
abacus-upstream = { workspace = true }
|
|
|
|
axum = { workspace = true }
|
|
tower = { workspace = true }
|
|
tower-http = { workspace = true }
|
|
tokio = { workspace = true }
|
|
tracing = { workspace = true }
|
|
tracing-subscriber = { workspace = true }
|
|
serde = { workspace = true }
|
|
serde_json = { workspace = true }
|
|
anyhow = { workspace = true }
|
|
subtle = { workspace = true }
|
|
hmac = { workspace = true }
|
|
sha2 = { workspace = true }
|
|
hex = { workspace = true }
|
|
ulid = { workspace = true }
|
|
async-trait = { workspace = true }
|
|
sqlx = { workspace = true }
|
|
|
|
[dev-dependencies]
|
|
abacus-testkit = { workspace = true }
|
|
tower = { workspace = true }
|