pub struct TokenIssuer { /* private fields */ }Expand description
A service’s token issuer: its signing key (rotatable, the old one kept in the JWKS for one token lifetime and the skew), the lifetime it mints, and the audit sink.
Implementations§
Source§impl TokenIssuer
impl TokenIssuer
Sourcepub fn new(key: PeerKey) -> Self
pub fn new(key: PeerKey) -> Self
An issuer signing with key, minting tokens of MAX_LIFETIME.
Sourcepub fn with_ttl(self, ttl: Duration) -> Self
pub fn with_ttl(self, ttl: Duration) -> Self
Tokens of ttl (at most MAX_LIFETIME).
Sourcepub fn with_audit(self, sink: Arc<dyn TokenAudit>) -> Self
pub fn with_audit(self, sink: Arc<dyn TokenAudit>) -> Self
Audit records also to sink.
Sourcepub fn jwks(&self) -> Jwks
pub fn jwks(&self) -> Jwks
The keys a peer verifies with: the current one, and each retired one while a token it signed may still be presented.
Sourcepub fn rotate(&self, new: PeerKey) -> String
pub fn rotate(&self, new: PeerKey) -> String
Sign with new from now; the old key stays in Self::jwks for one
token lifetime and the skew, then goes.
Sourcepub fn prove_forward(
&self,
token: &str,
claims: &PeerClaims,
) -> Result<String, TokenError>
pub fn prove_forward( &self, token: &str, claims: &PeerClaims, ) -> Result<String, TokenError>
KEEL-19: the service’s proof that it sends this forwarded hop — a
proof of possession (prove) by the key that signed claims’
token (its iss), over the token, its method and its call. A
verifying child takes a token bound to its own key only with this
proof (hop.proof), checked against the JWKS it trusts: on a pipe and
on a connection alike, whoever holds the token’s bytes alone cannot
present it.
Sourcepub fn mint(&self, req: MintRequest) -> Result<(String, PeerClaims), TokenError>
pub fn mint(&self, req: MintRequest) -> Result<(String, PeerClaims), TokenError>
Mint one forwarded call’s token (an exchange when req.presented).
Sourcepub fn mint_at(
&self,
req: MintRequest,
now: u64,
) -> Result<(String, PeerClaims), TokenError>
pub fn mint_at( &self, req: MintRequest, now: u64, ) -> Result<(String, PeerClaims), TokenError>
Self::mint as of now.
Sourcepub fn exchange_decided<F>(
&self,
subject: &str,
proof: Option<&str>,
audience: &str,
call: &str,
method: &str,
seen: &ProofCache,
decide: F,
) -> Result<(String, PeerClaims), TokenError>
pub fn exchange_decided<F>( &self, subject: &str, proof: Option<&str>, audience: &str, call: &str, method: &str, seen: &ProofCache, decide: F, ) -> Result<(String, PeerClaims), TokenError>
KEEL-19 · RFC 8693 token exchange, decided by the service: subject
(a token this issuer minted, bound to its audience’s key) presented
with proof (by that key, for EXCHANGE under the token’s call)
becomes a token for the audience decide names, of the scope it
decides — decide is handed the subject’s claims (its aud is the
presenter) and refuses with a ExchangeRefusal and why. The token
is bound to the presenter: its cnf is the subject’s, so the
audience takes it only with the presenter’s proof (hop.proof). A
subject is exchanged once per (jti, audience, method). Every
refusal is audited (ExchangeRefused); every exchange too.
audience is the name asked for (what a refusal’s record says).
Sourcepub fn verify_own(&self, token: &str) -> Result<PeerClaims, TokenError>
pub fn verify_own(&self, token: &str) -> Result<PeerClaims, TokenError>
A token this issuer minted (any audience), signature and times checked — what the issuer reads back when a peer presents it.