Skip to main content

ScopedKeyRing

Struct ScopedKeyRing 

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

A key ring holding scoped access tokens.

The root key is stored as a SecretKey so it is automatically zeroed on drop, preventing lingering key material in freed memory.

Implementations§

Source§

impl ScopedKeyRing

Source

pub fn new(root_key: [u8; 32]) -> Self

Create a new ScopedKeyRing from a root key.

Takes ownership of the raw bytes and wraps them in a SecretKey that will be zeroed on drop.

Source

pub fn create_token( &mut self, scope: &str, expires_at: Option<u64>, ) -> CryptoResult<&ScopedAccessToken>

Create a scoped access token for the given scope.

Source

pub fn get_key_for_scope(&self, scope: &str) -> Option<&ContentKey>

Get the derived key for a scope if a valid token exists.

Source

pub fn revoke_scope(&mut self, scope: &str) -> bool

Revoke all tokens for a scope.

Source

pub fn can_access(&self, path: &str) -> bool

Check if any valid token grants access to the given path.

Source

pub fn valid_tokens(&self) -> Vec<&ScopedAccessToken>

Get all valid (non-expired) tokens.

Source

pub fn token_count(&self) -> usize

Get the number of tokens (including expired ones).

Source

pub fn prune_expired(&mut self) -> usize

Remove all expired tokens.

Trait Implementations§

Source§

impl Debug for ScopedKeyRing

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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