Skip to main content

Module key_subject_resolver

Module key_subject_resolver 

Source
Expand description

Global signer-key → authorization-subject resolver (#446).

§Why this exists

The shared dispatch core (crate::service::dispatch::process_request) verifies every socket-served request — including same-uid local IPC over Unix domain sockets — under crate::envelope::EnvelopeVerification::AnySigner (iroh_rpc.rs::run_bridge_dispatch_loop hardcodes AnySigner, used by both the iroh network plane and uds_server). AnySigner cryptographically verifies the COSE composite against the envelope’s cnf (the signer’s Ed25519 pubkey) but produces key_derived_subject = anonymous — so a signed IPC request from one service to another loses its identity and is denied any policy-gated write (e.g. discovery:Announce).

The authoritative key→subject binding lives in the trust store (hyprstream-service::TrustStore, populated fail-closed under #441), but that crate sits above hyprstream-rpc in the dependency graph and cannot be referenced from the dispatch core. This module is the inversion-of-control seam: hyprstream-service installs a KeySubjectResolver at startup, and the default crate::service::RequestService::resolve_key_subject consults it. That makes every service (DiscoveryService included — it lives in hyprstream-discovery, which also cannot see the trust store) resolve a verified signer key to its authoritative service:<name> subject without each service crate having to depend on the trust store.

§Fail-closed invariant

Resolution NEVER fabricates an identity: an unregistered signer key resolves to None → anonymous. A genuinely anonymous caller (no registered key) therefore stays denied for policy-gated writes. This only honors the cryptographically-verified, registered identity of a legitimate signer — it never loosens a grant to anonymous.

Traits§

KeySubjectResolver
Resolves a verified Ed25519 signer pubkey to its authorization subject.

Functions§

resolve_subject
Resolve a signer key to a subject via the installed global resolver.
set_global
Install the global key→subject resolver.