pub struct LinkedCredential { /* private fields */ }Expand description
One credential, bound to the principal it authenticates.
Implementations§
Source§impl LinkedCredential
impl LinkedCredential
Sourcepub fn new(
class: CredentialClass,
locator: impl Into<String>,
principal: Principal,
) -> Self
pub fn new( class: CredentialClass, locator: impl Into<String>, principal: Principal, ) -> Self
Bind locator (a non-secret handle) to principal.
Sourcepub fn with_roles(self, roles: Vec<String>) -> Self
pub fn with_roles(self, roles: Vec<String>) -> Self
Roles this credential asserts.
Sourcepub fn with_claims(self, claims: Value) -> Self
pub fn with_claims(self, claims: Value) -> Self
Extra claims (org_id, username, …) this credential carries.
Sourcepub fn expiring_at(self, at: DateTime<Utc>) -> Self
pub fn expiring_at(self, at: DateTime<Utc>) -> Self
Give the credential a validity window.
Sourcepub fn created_at(self, at: DateTime<Utc>) -> Self
pub fn created_at(self, at: DateTime<Utc>) -> Self
Override the creation timestamp (for stores reading rows back).
Sourcepub fn class(&self) -> &CredentialClass
pub fn class(&self) -> &CredentialClass
The credential’s class.
Sourcepub fn is_revoked(&self) -> bool
pub fn is_revoked(&self) -> bool
Has this credential been withdrawn?
Sourcepub fn expires_at(&self) -> Option<DateTime<Utc>>
pub fn expires_at(&self) -> Option<DateTime<Utc>>
When it stops being valid, if ever.
Sourcepub fn is_expired_at(&self, now: DateTime<Utc>) -> bool
pub fn is_expired_at(&self, now: DateTime<Utc>) -> bool
Is this credential past its validity window at now?
A credential with no expires_at never expires — that is today’s
behavior for API keys with a null expires_at column and is
preserved deliberately.
Trait Implementations§
Source§impl Clone for LinkedCredential
impl Clone for LinkedCredential
Source§impl Debug for LinkedCredential
impl Debug for LinkedCredential
Source§impl PartialEq for LinkedCredential
impl PartialEq for LinkedCredential
impl StructuralPartialEq for LinkedCredential
Auto Trait Implementations§
impl Forget for LinkedCredential
impl Freeze for LinkedCredential
impl RefUnwindSafe for LinkedCredential
impl Send for LinkedCredential
impl Sync for LinkedCredential
impl Unpin for LinkedCredential
impl UnsafeUnpin for LinkedCredential
impl UnwindSafe for LinkedCredential
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