pub struct TokenAuthority { /* private fields */ }Expand description
The token table, backed by chain events.
Implementations§
Source§impl TokenAuthority
impl TokenAuthority
Sourcepub fn new(chain: Arc<ChainManager>, node_id: impl Into<String>) -> Self
pub fn new(chain: Arc<ChainManager>, node_id: impl Into<String>) -> Self
Build the authority over chain (no journal) and replay it.
Sourcepub fn with_journal(
chain: Arc<ChainManager>,
node_id: impl Into<String>,
journal: Option<PathBuf>,
) -> Self
pub fn with_journal( chain: Arc<ChainManager>, node_id: impl Into<String>, journal: Option<PathBuf>, ) -> Self
Build the authority with a durable revocation journal at journal
(see the module docs). None means revocations are not crash-durable.
Sourcepub fn chain_refs(&self) -> usize
pub fn chain_refs(&self) -> usize
Strong references to the underlying chain (the authority holds one).
Sourcepub fn rebuild_at(&self, now: DateTime<Utc>)
pub fn rebuild_at(&self, now: DateTime<Utc>)
Replay the chain and journal: issued minus revoked minus expired at
now. Only events from SOURCE count.
Sourcepub fn issue(
&self,
label: &str,
ttl: Option<Duration>,
project: Option<String>,
issuer: &Issuer,
) -> Result<(String, TokenInfo), TokenError>
pub fn issue( &self, label: &str, ttl: Option<Duration>, project: Option<String>, issuer: &Issuer, ) -> Result<(String, TokenInfo), TokenError>
Issue a token. Returns the secret (shown once) and its metadata.
Sourcepub fn issue_at(
&self,
now: DateTime<Utc>,
label: &str,
ttl: Option<Duration>,
project: Option<String>,
issuer: &Issuer,
) -> Result<(String, TokenInfo), TokenError>
pub fn issue_at( &self, now: DateTime<Utc>, label: &str, ttl: Option<Duration>, project: Option<String>, issuer: &Issuer, ) -> Result<(String, TokenInfo), TokenError>
Self::issue at an explicit clock.
Sourcepub fn issue_project(
&self,
project_id: &str,
ttl: Duration,
issuer: &Issuer,
) -> Result<(String, TokenInfo), TokenError>
pub fn issue_project( &self, project_id: &str, ttl: Duration, issuer: &Issuer, ) -> Result<(String, TokenInfo), TokenError>
Issue a TokenScope::Project token for project_id: Write only,
never Admin, valid for ttl.
Sourcepub fn issue_scoped_at(
&self,
now: DateTime<Utc>,
label: &str,
ttl: Option<Duration>,
project: Option<String>,
scope: TokenScope,
issuer: &Issuer,
) -> Result<(String, TokenInfo), TokenError>
pub fn issue_scoped_at( &self, now: DateTime<Utc>, label: &str, ttl: Option<Duration>, project: Option<String>, scope: TokenScope, issuer: &Issuer, ) -> Result<(String, TokenInfo), TokenError>
Issue with an explicit scope at an explicit clock.
Sourcepub fn revoke(&self, id: &str) -> Result<bool, TokenError>
pub fn revoke(&self, id: &str) -> Result<bool, TokenError>
Revoke by id. Returns whether a live token was revoked. The token stops validating immediately even if journaling then fails (the error is returned so the caller knows the revocation may not survive a crash).
Sourcepub fn validate(&self, secret: &str) -> Option<TokenInfo>
pub fn validate(&self, secret: &str) -> Option<TokenInfo>
Validate a presented secret. Compares hashes in constant time.
Sourcepub fn validate_at(&self, now: DateTime<Utc>, secret: &str) -> Option<TokenInfo>
pub fn validate_at(&self, now: DateTime<Utc>, secret: &str) -> Option<TokenInfo>
Self::validate at an explicit clock.
Auto Trait Implementations§
impl !Freeze for TokenAuthority
impl RefUnwindSafe for TokenAuthority
impl Send for TokenAuthority
impl Sync for TokenAuthority
impl Unpin for TokenAuthority
impl UnsafeUnpin for TokenAuthority
impl UnwindSafe for TokenAuthority
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more