pub struct AccessToken(/* private fields */);Expand description
A per-process bearer token. Never persisted, never logged except by explicit
request in --server mode, and compared in (best-effort) constant time.
Implementations§
Source§impl AccessToken
impl AccessToken
Sourcepub fn generate() -> Result<Self, SecurityError>
pub fn generate() -> Result<Self, SecurityError>
A fresh 256-bit token from the OS CSPRNG.
§Errors
SecurityError::Random if the platform entropy source fails.
Sourcepub fn parse(raw: &str) -> Result<Self, SecurityError>
pub fn parse(raw: &str) -> Result<Self, SecurityError>
Adopt a caller-supplied token, rejecting anything outside
[A-Za-z0-9._-]{16,128}. The character set matters: the token is
placed in the GUI’s initialization script and in the --server launch
URL’s fragment, and a quote, </script> or & in either would be an
injection or a mangled credential.
§Errors
SecurityError::MalformedToken if raw is too short, too long, or
contains a character outside the allowed set.
pub fn as_str(&self) -> &str
Sourcepub fn matches(&self, presented: &str) -> bool
pub fn matches(&self, presented: &str) -> bool
Best-effort constant-time comparison. The values are 256-bit random, so a timing oracle over loopback HTTP is not a practical attack; this only avoids handing one out for free. (Rust makes no formal guarantee that the optimiser preserves this; a dedicated crate would.)
Public for an app that accepts the token (or a second secret of its
own) somewhere token_guard does not reach: the invoicer’s gate over
MBR’s pages, which a browser loads by navigation, with a cookie.
Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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