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 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(
&self,
subject: &str,
proof: Option<&str>,
name: &str,
peer_key: Option<String>,
requested: Option<&[String]>,
call: &str,
method: &str,
seen: &ProofCache,
) -> Result<(String, PeerClaims), TokenError>
pub fn exchange( &self, subject: &str, proof: Option<&str>, name: &str, peer_key: Option<String>, requested: Option<&[String]>, call: &str, method: &str, seen: &ProofCache, ) -> Result<(String, PeerClaims), TokenError>
RFC 8693 token exchange, as a method answers it: subject (a token
this issuer minted, presented by its audience with proof when it is
key-bound) becomes a token for audience (peer_key, a name for a
pipe), its scope requested narrowed by the presented one.
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.