pub struct LinkToken {
pub token_hash: String,
pub role: FleetRole,
pub scope: GrantScope,
pub person: Option<String>,
pub minted_by: FleetActor,
pub minted_at: i64,
pub expires_at: i64,
pub consumed: Option<Consumption>,
}Expand description
A one-time, expiring token that lets a person claim an account.
Fields§
§token_hash: StringLinkSecret::hash of the secret. The secret itself is never stored.
role: FleetRole§scope: GrantScope§person: Option<String>Some when the token adds an account to an existing person.
minted_by: FleetActor§minted_at: i64§expires_at: i64Redemption fails at or after this time.
consumed: Option<Consumption>Implementations§
Source§impl LinkToken
impl LinkToken
pub const KIND: RecordKind = RecordKind::LinkToken
Sourcepub fn new(
secret: &LinkSecret,
role: FleetRole,
scope: GrantScope,
person: Option<String>,
minted_by: FleetActor,
minted_at: i64,
expires_at: i64,
) -> Self
pub fn new( secret: &LinkSecret, role: FleetRole, scope: GrantScope, person: Option<String>, minted_by: FleetActor, minted_at: i64, expires_at: i64, ) -> Self
An unconsumed token for secret, storing only the secret’s hash.
Sourcepub fn key_for_secret(secret: &LinkSecret) -> RecordKey
pub fn key_for_secret(secret: &LinkSecret) -> RecordKey
The key a presented secret’s token lives at.
Sourcepub fn redeem(
&self,
secret: &LinkSecret,
person: &str,
binding: RecordKey,
now_ms: i64,
) -> Result<LinkToken, RedeemError>
pub fn redeem( &self, secret: &LinkSecret, person: &str, binding: RecordKey, now_ms: i64, ) -> Result<LinkToken, RedeemError>
This token marked consumed by person into binding at now_ms.
Write the result with Store::put(record, Some(read_revision)), so a
concurrent redemption of the same revision is a Conflict. Checks run
in order: wrong secret, expired, already consumed, person mismatch.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LinkToken
impl<'de> Deserialize<'de> for LinkToken
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 LinkToken
Source§impl RecordCodec for LinkToken
impl RecordCodec for LinkToken
impl StructuralPartialEq for LinkToken
Auto Trait Implementations§
impl Freeze for LinkToken
impl RefUnwindSafe for LinkToken
impl Send for LinkToken
impl Sync for LinkToken
impl Unpin for LinkToken
impl UnsafeUnpin for LinkToken
impl UnwindSafe for LinkToken
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