Skip to main content

Tokens

Struct Tokens 

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

The in-memory token table. Keys are either an opaque bearer token or a dummy AWS access key id; both map to (policy, expiry, optional secret).

Implementations§

Source§

impl Tokens

Source

pub fn new() -> Self

Source

pub fn mint( &self, policy: Policy, ttl_seconds: u64, now_ms: u64, ) -> MintResponse

Mint a fresh token bound to policy, valid for ttl_seconds from now_ms.

Source

pub fn mint_sigv4( &self, policy: Policy, ttl_seconds: u64, now_ms: u64, ) -> SigV4Mint

Mint a dummy AWS SigV4 credential bound to policy. The access key id is the lookup key; the secret is stored to verify inbound signatures.

Source

pub fn resolve_sigv4( &self, access_key_id: &str, now_ms: u64, ) -> Option<(Policy, String)>

Resolve a dummy AWS access key id to its bound policy and dummy secret, or None if unknown, expired, or not a SigV4 credential.

Source

pub fn resolve(&self, token: &str, now_ms: u64) -> Option<Policy>

Resolve a token to its bound policy, or None if unknown or expired at now_ms.

Source

pub fn resolve_full(&self, token: &str, now_ms: u64) -> Option<(Policy, u64)>

Resolve a token to its bound policy and absolute expiry, or None if unknown or expired at now_ms. Used by the provision projection.

Source

pub fn revoke(&self, token: &str) -> bool

Revoke a token immediately. Returns whether a token was removed.

Source

pub fn sweep(&self, now_ms: u64) -> usize

Evict every entry expired at now_ms, returning how many were removed. resolve already refuses expired entries, but without this the table only grows — every SigV4 /provision mints a dummy credential that would otherwise never be reclaimed. A background sweeper calls this periodically.

Source

pub fn len(&self) -> usize

The number of live (un-swept) entries. For metrics/tests.

Source

pub fn is_empty(&self) -> bool

Whether the token table is empty.

Trait Implementations§

Source§

impl Default for Tokens

Source§

fn default() -> Tokens

Returns the “default value” for a type. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more