pub struct TokenIssuer { /* private fields */ }Expand description
Mints and verifies capability tokens. The supervisor holds one instance; the secret is generated once per process and never written to disk.
Implementations§
Source§impl TokenIssuer
impl TokenIssuer
pub fn new(secret: Vec<u8>) -> Self
Sourcepub fn new_random() -> Self
pub fn new_random() -> Self
New issuer with a fresh 32-byte random secret (secrets.token_bytes(32)).
Sourcepub fn mint(
&self,
plugin_id: &str,
granted_caps: &BTreeSet<String>,
ttl_seconds: i64,
) -> CapabilityToken
pub fn mint( &self, plugin_id: &str, granted_caps: &BTreeSet<String>, ttl_seconds: i64, ) -> CapabilityToken
Mint a token using the current wall clock and a fresh random session id.
Sourcepub fn mint_at(
&self,
plugin_id: &str,
granted_caps: &BTreeSet<String>,
ttl_seconds: i64,
now: i64,
session_id: &str,
) -> CapabilityToken
pub fn mint_at( &self, plugin_id: &str, granted_caps: &BTreeSet<String>, ttl_seconds: i64, now: i64, session_id: &str, ) -> CapabilityToken
Deterministic mint core (explicit clock + session) for tests and replay.
Sourcepub fn verify(
&self,
token: &CapabilityToken,
now: i64,
) -> Result<(), TokenError>
pub fn verify( &self, token: &CapabilityToken, now: i64, ) -> Result<(), TokenError>
Verify the HMAC and expiry. now is unix seconds.
Auto Trait Implementations§
impl Freeze for TokenIssuer
impl RefUnwindSafe for TokenIssuer
impl Send for TokenIssuer
impl Sync for TokenIssuer
impl Unpin for TokenIssuer
impl UnsafeUnpin for TokenIssuer
impl UnwindSafe for TokenIssuer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more