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
impl ScopedKeyRing
Sourcepub fn new(root_key: [u8; 32]) -> Self
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.
Sourcepub fn create_token(
&mut self,
scope: &str,
expires_at: Option<u64>,
) -> CryptoResult<&ScopedAccessToken>
pub fn create_token( &mut self, scope: &str, expires_at: Option<u64>, ) -> CryptoResult<&ScopedAccessToken>
Create a scoped access token for the given scope.
Sourcepub fn get_key_for_scope(&self, scope: &str) -> Option<&ContentKey>
pub fn get_key_for_scope(&self, scope: &str) -> Option<&ContentKey>
Get the derived key for a scope if a valid token exists.
Sourcepub fn revoke_scope(&mut self, scope: &str) -> bool
pub fn revoke_scope(&mut self, scope: &str) -> bool
Revoke all tokens for a scope.
Sourcepub fn can_access(&self, path: &str) -> bool
pub fn can_access(&self, path: &str) -> bool
Check if any valid token grants access to the given path.
Sourcepub fn valid_tokens(&self) -> Vec<&ScopedAccessToken>
pub fn valid_tokens(&self) -> Vec<&ScopedAccessToken>
Get all valid (non-expired) tokens.
Sourcepub fn token_count(&self) -> usize
pub fn token_count(&self) -> usize
Get the number of tokens (including expired ones).
Sourcepub fn prune_expired(&mut self) -> usize
pub fn prune_expired(&mut self) -> usize
Remove all expired tokens.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ScopedKeyRing
impl RefUnwindSafe for ScopedKeyRing
impl Send for ScopedKeyRing
impl Sync for ScopedKeyRing
impl Unpin for ScopedKeyRing
impl UnsafeUnpin for ScopedKeyRing
impl UnwindSafe for ScopedKeyRing
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