pub struct ProxyToken { /* private fields */ }Expand description
The minted token, as the control plane returns it: a map of header name to value.
Deliberately opaque. There is no as_str, no Display, and no Deref, because
the TRAP-7 mistake is treating this value as the token string — and a type that
cannot be printed as one cannot be used as one. ProxyToken::auth_value is the
only way out, and it names the header it reads so the call site says which key of
the map it means.
Implementations§
Source§impl ProxyToken
impl ProxyToken
Sourcepub fn new(headers: HashMap<String, String>) -> ProxyToken
pub fn new(headers: HashMap<String, String>) -> ProxyToken
Wraps the authToken map from a CreateMicrovmAuthToken response.
Sourcepub fn from_pairs<I, K, V>(pairs: I) -> ProxyToken
pub fn from_pairs<I, K, V>(pairs: I) -> ProxyToken
The map as pairs, for a caller that already has them.
Sourcepub fn get(&self, name: &str) -> Option<&str>
pub fn get(&self, name: &str) -> Option<&str>
One header’s value, matched case-insensitively.
Case-insensitively because HTTP header names are, and the map’s keys come from
a service response rather than from this crate: a client that matched
X-aws-proxy-auth exactly would break on a response that spelled it
x-aws-proxy-auth, and the failure would be a missing header rather than a
missing key.
Sourcepub fn headers(&self) -> impl Iterator<Item = (&str, &str)>
pub fn headers(&self) -> impl Iterator<Item = (&str, &str)>
Every header the token carries, in unspecified order.
Public because the platform’s stated reason for a map is that a scheme may need more than one header, so a client that forwarded only the two it knows about would silently drop a third the service started sending.
Sourcepub fn auth_value(&self) -> Result<&str, Error>
pub fn auth_value(&self) -> Result<&str, Error>
The PROXY_AUTH_HEADER value, or a retryable mint failure if the map has no
such key.
Retryable rather than a protocol error: an authToken map without the auth
header is a control-plane response this client cannot use, which is the same
situation as a mint that failed outright, and the same remedy applies.
Trait Implementations§
Source§impl Clone for ProxyToken
impl Clone for ProxyToken
Source§fn clone(&self) -> ProxyToken
fn clone(&self) -> ProxyToken
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProxyToken
Names the keys and never the values.
impl Debug for ProxyToken
Names the keys and never the values.
A proxy token is a credential, and a Debug that printed it would put it in every
log line that formats a ProxyAuth or an error chain containing one.
Source§impl Default for ProxyToken
impl Default for ProxyToken
Source§fn default() -> ProxyToken
fn default() -> ProxyToken
Source§impl From<ProxyToken> for ProxyToken
The seam to the control plane’s own token type.
impl From<ProxyToken> for ProxyToken
The seam to the control plane’s own token type.
The two lanes that landed this module and crate::control arrived at the same trap
closure from different directions: control::ProxyToken keeps the auth value and the
port as two fields and emits a fixed pair from headers(), while this one keeps the
service’s whole map so a third header the platform adds later rides along without a
code change. Neither is wrong, and unifying them would mean one lane editing the
other’s module.
So the conversion lives here, which is the side that consumes it. It is the whole of
what a caller needs to hand ControlPlane::mint_auth_token’s result to a
TokenMinter, and it is From rather than a named function so the wiring is one
.into() at the boundary.
Source§fn from(token: ProxyToken) -> ProxyToken
fn from(token: ProxyToken) -> ProxyToken
Auto Trait Implementations§
impl Freeze for ProxyToken
impl RefUnwindSafe for ProxyToken
impl Send for ProxyToken
impl Sync for ProxyToken
impl Unpin for ProxyToken
impl UnsafeUnpin for ProxyToken
impl UnwindSafe for ProxyToken
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,
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