pub struct ServiceToken {
pub token_id: String,
pub principal: String,
pub scopes: Vec<String>,
pub secret_sha256: String,
pub expires_unix: u64,
}Expand description
Service token (bearer) bound to a principal name and scope set.
Fields§
§token_id: StringToken id.
principal: StringPrincipal name.
scopes: Vec<String>Scopes.
secret_sha256: StringSHA-256 of the raw secret (never store the raw secret).
expires_unix: u64Expiry unix seconds (0 = non-expiring).
Implementations§
Source§impl ServiceToken
impl ServiceToken
Sourcepub fn mint(
token_id: impl Into<String>,
principal: impl Into<String>,
scopes: Vec<String>,
raw_secret: &str,
expires_unix: u64,
) -> Self
pub fn mint( token_id: impl Into<String>, principal: impl Into<String>, scopes: Vec<String>, raw_secret: &str, expires_unix: u64, ) -> Self
Mint metadata from a raw secret (stores only the hash).
Sourcepub fn verify_secret(&self, raw_secret: &str, now_unix: u64) -> bool
pub fn verify_secret(&self, raw_secret: &str, now_unix: u64) -> bool
Verify a presented raw secret.
Trait Implementations§
Source§impl Clone for ServiceToken
impl Clone for ServiceToken
Source§fn clone(&self) -> ServiceToken
fn clone(&self) -> ServiceToken
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ServiceToken
impl Debug for ServiceToken
Source§impl<'de> Deserialize<'de> for ServiceToken
impl<'de> Deserialize<'de> for ServiceToken
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ServiceToken
Source§impl PartialEq for ServiceToken
impl PartialEq for ServiceToken
Source§impl Serialize for ServiceToken
impl Serialize for ServiceToken
impl StructuralPartialEq for ServiceToken
Auto Trait Implementations§
impl Freeze for ServiceToken
impl RefUnwindSafe for ServiceToken
impl Send for ServiceToken
impl Sync for ServiceToken
impl Unpin for ServiceToken
impl UnsafeUnpin for ServiceToken
impl UnwindSafe for ServiceToken
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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>
Converts
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>
Converts
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