pub enum TokenError {
Missing,
Malformed,
Invalid,
Expired,
Unavailable(Error),
}Expand description
Why a presented token was not accepted.
An unknown id and a wrong secret are the same variant on purpose. They are indistinguishable to the caller, and keeping them apart in the type is how somebody eventually writes a message — or a log line, or a metric — that tells an attacker which of their guesses was half right.
Variants§
Missing
No Authorization: Bearer header at all.
Malformed
Present, but not shaped like <id>|<secret>.
Invalid
No such token, or the wrong secret for it.
Expired
The right secret for a token that is past its expiry.
The store itself failed. Ours, not the caller’s.
Implementations§
Source§impl TokenError
impl TokenError
Sourcepub fn message(&self) -> &'static str
pub fn message(&self) -> &'static str
What the client is told. Never mentions the token it presented.
pub fn status(&self) -> Status
Sourcepub fn challenge(&self) -> &'static str
pub fn challenge(&self) -> &'static str
The WWW-Authenticate challenge, per RFC 6750.
A bare Bearer when nothing was presented — the client may simply not
know it needed to authenticate — and error="invalid_token" when
something was, which tells a correct client to stop retrying with the
credential it has and go get another one.
Trait Implementations§
Source§impl Debug for TokenError
impl Debug for TokenError
Source§impl Display for TokenError
impl Display for TokenError
Source§impl Error for TokenError
impl Error for TokenError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()