pub trait RequestSigner: Send + Sync {
// Required method
fn sign(
&self,
method: &str,
authority: &str,
path: &str,
body: &[u8],
) -> Vec<(String, String)>;
// Provided methods
fn on_response(&self, _resp: &AuthResponse, _authority: &str) -> bool { ... }
fn capabilities(&self) -> Option<String> { ... }
fn wants_content_digest(&self, _authority: &str) -> bool { ... }
}Expand description
A per-request signer (RFC 0023 — AAuth). The transport calls [sign] just
before each POST (the returned (name, value) pairs become request headers —
the RFC 9421 Signature-Input/Signature/Signature-Key), and
[on_response] after, to react to the server’s AAuth-Requirement (adopt an
access token, run the Person-Server flow) and re-sign+retry. Kept
dependency-free here — the CRYPTO lives in the caller (agentd’s aauth
module); this crate only owns the seam, so agentd-mcp gains no crypto dep.
Required Methods§
Sourcefn sign(
&self,
method: &str,
authority: &str,
path: &str,
body: &[u8],
) -> Vec<(String, String)>
fn sign( &self, method: &str, authority: &str, path: &str, body: &[u8], ) -> Vec<(String, String)>
Sign one request. authority is the Host value (host[:port]); path
is the request-target. body is the JSON-RPC bytes (for a
content-digest cover when the server requires it). Returns headers to
add; an empty vec = send unsigned (let the server answer with its
requirement).
Provided Methods§
Sourcefn on_response(&self, _resp: &AuthResponse, _authority: &str) -> bool
fn on_response(&self, _resp: &AuthResponse, _authority: &str) -> bool
React to a response (RFC 0023 §5): adopt an AAuth-Access token, satisfy
an AAuth-Requirement (e.g. run the Person-Server exchange), and return
true iff the request should be RE-SIGNED and retried (a requirement was
newly satisfied). The default reacts to nothing. May do network I/O
(the PS token exchange).
Sourcefn capabilities(&self) -> Option<String>
fn capabilities(&self) -> Option<String>
An optional AAuth-Capabilities header value (interaction shapes the
agent can drive). None = omit.
Sourcefn wants_content_digest(&self, _authority: &str) -> bool
fn wants_content_digest(&self, _authority: &str) -> bool
Whether this server requires a content-digest cover (learned at
discovery). The transport adds/covers the body digest when true.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".