Skip to main content

InMemoryTokenBroker

Struct InMemoryTokenBroker 

Source
pub struct InMemoryTokenBroker { /* private fields */ }
Expand description

Reference broker for unit tests + small deployments. Production adopters should implement their own TokenBroker against a real secret manager (Vault, AWS Secrets Manager, Doppler, …).

SP-capability-v2 (2026-05-11): gained a UCAN-JWT branch in TokenBroker::resolve_bearer. Adopters register a mapping from a UCAN did:key:z... audience to the caller id they want assigned to that DID via Self::register_ucan_audience. JWT-shape bearers then resolve to that caller id with the chain’s attenuated caps. Non-JWT bearers continue to return BrokerError::NotConfigured (unchanged from phase 1).

Implementations§

Source§

impl InMemoryTokenBroker

Source

pub fn new() -> Self

Source

pub fn insert(&mut self, caller_id: impl Into<String>, bundle: SecretBundle)

Source

pub fn register_ucan_audience( &mut self, did_key: impl Into<String>, caller_id: impl Into<String>, )

Register a UCAN did:key:z... audience as a known identity for this broker. A UCAN bearer whose leaf aud matches did_key will resolve to BearerIdentity::caller_id = caller_id.

SP-capability-v2 §4.6 + §6 — celia’s analogous mapping is the new consent.did_to_grantee column.

Source

pub fn with_max_chain_depth(self, depth: u8) -> Self

Set the verifier’s max chain depth (default 5).

Source

pub fn with_revocation_store(self, store: Arc<dyn UcanRevocationStore>) -> Self

Attach a revocation store consulted on every UCAN link.

Trait Implementations§

Source§

impl Default for InMemoryTokenBroker

Source§

fn default() -> InMemoryTokenBroker

Returns the “default value” for a type. Read more
Source§

impl TokenBroker for InMemoryTokenBroker

Source§

fn resolve<'a>(&'a self, caller_id: Option<&'a str>) -> ResolveFuture<'a>

Resolve a secret bundle for the given caller. Read more
Source§

fn accepted_token_formats(&self) -> &'static [&'static str]

Hint to the operator + diagnostics paths about which token format(s) this broker accepts (e.g. ["ce-pairing-code"], ["jwt-rs256"], ["opaque"]). Listener does NOT route on this — it is informational, surfaced through atd-ref-server --doctor and the /initialize server-info echo. Default &[] means “unspecified / introspect via try-resolve”. SP-token-broker-phase2 §4.2.
Source§

fn resolve_bearer<'a>(&'a self, bearer: &'a str) -> ResolveBearerFuture<'a>

Resolve a bearer token (from an HTTP Authorization: Bearer … header) to a BearerIdentity. The HTTP listener calls this once per request before dispatch (SP-streamable-http §4.3). Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V