Skip to content

Commit 2a02440

Browse files
rmichelenaravarora2claude
committed
fix(relay): record the NIP-OA owner for direct members on closed relays
On a closed relay an agent that is itself a relay member never gets its NIP-OA owner recorded, however many valid attestations it presents. `enforce_relay_membership` returns `Ok(None)` as soon as direct membership is established, and the only owner-extraction fallback at either call site was gated on `!require_relay_membership` — off precisely where it is needed. With `agent_owner_pubkey` left NULL the relay cannot tell the agent from a human: `owner_only` policies have nothing to match, observer frames are refused, and the connection is rate-classed as human. Closes block#4223, block#4937. `relay_members::resolve_nip_oa_owner` settles the question once for both call sites. Admission by delegation keeps the owner it already proved is a member; an open relay keeps today's behaviour; a direct member on a closed relay has its attestation resolved, with the owner required to be a relay member. That membership requirement is load-bearing. `materialize_nip_oa_owner` is first-write-wins and the recorded owner selects the agent rate class, so without it any member could attest itself with a throwaway key, raise its own rate budget, and bind the mapping permanently against the real owner. `allow_nip_oa_auth` deliberately does not gate this: per its own doc comment the flag governs whether NIP-OA may *grant membership* on a closed relay, and nothing here grants access — the caller is already in. Time bounds now come from block#7004 (`verify_auth_tag_for_auth_event` and the `signed_created_at` carried on `VerifiedBridgeAuth`), so this branch builds on those primitives rather than duplicating them. Nine tests exercise both production paths against real PostgreSQL and Redis: `submit_event_authed` and the full `POST /events` router, plus `handle_auth` on the WebSocket side. They live in `postgres_tests` modules so the structural PostgreSQL discovery lane picks them up, which is why this branch no longer patches `ci.yml`. Co-authored-by: Ravneet Arora <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Roberto Michelena <[email protected]>
1 parent 4cd82f5 commit 2a02440

3 files changed

Lines changed: 745 additions & 31 deletions

File tree

0 commit comments

Comments
 (0)