pub struct RotateRefreshToken {
pub session_id: SessionId,
pub family: SessionFamilyRecord,
pub lease: RenewalLease,
pub previous_refresh_token_hash: RefreshTokenHash,
pub next_refresh_token_hash: RefreshTokenHash,
pub next_session: SessionRecord,
}Expand description
Input required to atomically rotate a refresh token.
§Examples
use std::time::{Duration, SystemTime};
use webgates_sessions::lease::{LeaseId, LeaseTtl, RenewalLease};
use webgates_sessions::repository::RotateRefreshToken;
use webgates_sessions::session::{Session, SessionFamilyId, SessionFamilyRecord};
use webgates_sessions::tokens::RefreshTokenHash;
let now = SystemTime::UNIX_EPOCH + Duration::from_secs(1_000);
let family_id = SessionFamilyId::new();
let session = Session::new(
family_id,
"user-42",
now,
now + Duration::from_secs(3_600),
);
let family = SessionFamilyRecord::new(family_id, "user-42", now);
let lease = RenewalLease::from_ttl(
session.session_id,
LeaseId::new(),
now,
LeaseTtl::new(Duration::from_secs(30)),
);
let input = RotateRefreshToken {
session_id: session.session_id,
family,
lease,
previous_refresh_token_hash: RefreshTokenHash::new("prev-hash-abc").unwrap(),
next_refresh_token_hash: RefreshTokenHash::new("next-hash-xyz").unwrap(),
next_session: session.clone().touched(now),
};
assert_eq!(input.session_id, session.session_id);Fields§
§session_id: SessionIdSession that is being renewed.
family: SessionFamilyRecordSession family that owns the session.
lease: RenewalLeaseLease expected to authorize this rotation.
previous_refresh_token_hash: RefreshTokenHashPreviously active refresh-token hash.
next_refresh_token_hash: RefreshTokenHashNewly issued refresh-token hash to persist.
next_session: SessionRecordUpdated session record that should become current after rotation.
Trait Implementations§
Source§impl Clone for RotateRefreshToken
impl Clone for RotateRefreshToken
Source§fn clone(&self) -> RotateRefreshToken
fn clone(&self) -> RotateRefreshToken
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 RotateRefreshToken
impl Debug for RotateRefreshToken
Source§impl PartialEq for RotateRefreshToken
impl PartialEq for RotateRefreshToken
Source§fn eq(&self, other: &RotateRefreshToken) -> bool
fn eq(&self, other: &RotateRefreshToken) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for RotateRefreshToken
impl StructuralPartialEq for RotateRefreshToken
Auto Trait Implementations§
impl Freeze for RotateRefreshToken
impl RefUnwindSafe for RotateRefreshToken
impl Send for RotateRefreshToken
impl Sync for RotateRefreshToken
impl Unpin for RotateRefreshToken
impl UnsafeUnpin for RotateRefreshToken
impl UnwindSafe for RotateRefreshToken
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