pub struct AccessToken(/* private fields */);Expand description
A one-time secret that lets a communication client start a session.
S2C-OAS common: “valid for one time login, with a maximum 5 years”, Base64, at least
32 bytes.
Implementations§
Source§impl AccessToken
impl AccessToken
Sourcepub fn from_entropy(bytes: &[u8]) -> Result<Self, ConnectError>
pub fn from_entropy(bytes: &[u8]) -> Result<Self, ConnectError>
Generate one from 32 bytes of cryptographically secure randomness.
The bytes are a parameter rather than drawn here, so the protocol layer stays pure and a test can pin them.
Sourcepub fn verify(&self, other: &Self) -> bool
pub fn verify(&self, other: &Self) -> bool
Whether another token is this one, compared in constant time.
Sourcepub fn verify_str(&self, presented: &str) -> bool
pub fn verify_str(&self, presented: &str) -> bool
Whether a token as it arrived on the wire is this one, compared in constant time.
A short-circuiting == on a bearer token leaks its prefix to anyone who
can time the answer, which is why these types have no PartialEq at all:
there is no way to compare them carelessly.
Trait Implementations§
Source§impl Clone for AccessToken
impl Clone for AccessToken
Source§impl Debug for AccessToken
impl Debug for AccessToken
Source§impl<'de> Deserialize<'de> for AccessToken
impl<'de> Deserialize<'de> for AccessToken
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
Source§impl Drop for AccessToken
impl Drop for AccessToken
Source§impl Serialize for AccessToken
impl Serialize for AccessToken
Auto Trait Implementations§
impl Forget for AccessToken
impl Freeze for AccessToken
impl Move for AccessToken
impl RefUnwindSafe for AccessToken
impl Send for AccessToken
impl Sync for AccessToken
impl Unpin for AccessToken
impl UnsafeUnpin for AccessToken
impl UnwindSafe for AccessToken
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