pub struct Credentials<'a> { /* private fields */ }Expand description
What a request presented, for an authenticator to judge.
Borrowed rather than owned because the only field is a header value that is
already in the request, and copying an Authorization header into a
long-lived struct is exactly the kind of retention the redaction rule is
about.
Debug is written by hand below rather than derived. The derive would print
the raw Authorization header — that is, the bearer token — into any
{:?} this type meets: a panic message, a failed assertion, a log line
somebody adds while debugging. The field’s own doc comment used to say this
crate never logs it, which was true and was not a property of anything.
Implementations§
Source§impl<'a> Credentials<'a>
impl<'a> Credentials<'a>
Sourcepub fn from_headers(headers: &'a HeaderMap) -> Self
pub fn from_headers(headers: &'a HeaderMap) -> Self
Reads the Authorization header out of a request.
The raw Authorization value.
Present for an implementor that has to parse it. This crate never logs
it, and the doc comment on Credentials is the reason: the rule is
“never log tokens”, and the way that is kept is by this being the only
path to the value and by nothing in this module formatting it.
Trait Implementations§
Source§impl<'a> Clone for Credentials<'a>
impl<'a> Clone for Credentials<'a>
impl<'a> Copy for Credentials<'a>
Source§impl Debug for Credentials<'_>
impl Debug for Credentials<'_>
Source§fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
Prints a fingerprint, never the header.
The same shape as
RequestId::redacted: a short
prefix and a length, so two log lines can be correlated without either
carrying the credential. Four characters of a 256-bit token is not a
meaningful reduction in the search space, and correlation is worth it.