pub struct TokenExchange { /* private fields */ }Expand description
An identity provider’s token endpoint, used for RFC 8693 exchanges,
authenticated with this agent’s client credentials as
OAuth2ClientCredentials is.
Implementations§
Source§impl TokenExchange
impl TokenExchange
Sourcepub fn new(
token_url: impl Into<String>,
client_id: impl Into<String>,
client_secret: impl Into<String>,
) -> TokenExchange
pub fn new( token_url: impl Into<String>, client_id: impl Into<String>, client_secret: impl Into<String>, ) -> TokenExchange
The token endpoint at token_url, authenticated as client_id.
Sourcepub fn with_tls_config(self, tls: ClientConfig) -> TokenExchange
Available on crate feature tls-rustls only.
pub fn with_tls_config(self, tls: ClientConfig) -> TokenExchange
tls-rustls only.Connects to the token endpoint with tls: an identity provider behind
a private CA, or one that asks for a client certificate. A
configuration given here is exact; without it the roots are Mozilla’s
plus those SSL_CERT_FILE and SSL_CERT_DIR name, and no client
certificate is presented (audit B-03).
Sourcepub const fn allow_insecure_token_endpoint(self) -> TokenExchange
pub const fn allow_insecure_token_endpoint(self) -> TokenExchange
Allows a plaintext http:// token endpoint on a host other than
loopback. Off by default: an exchange carries the user’s subject token
and this agent’s client secret, and sent in the clear both can be read
by anyone on the path.
Sourcepub const fn with_auth_style(
self,
style: TokenEndpointAuthStyle,
) -> TokenExchange
pub const fn with_auth_style( self, style: TokenEndpointAuthStyle, ) -> TokenExchange
Sets how the client credentials are presented (default
TokenEndpointAuthStyle::Basic).
Sourcepub const fn with_request_timeout(self, timeout: Duration) -> TokenExchange
pub const fn with_request_timeout(self, timeout: Duration) -> TokenExchange
Sets the time one exchange may take, headers and body together (default 30 s).
Sourcepub async fn exchange(
&self,
request: &ExchangeRequest,
) -> Result<ExchangedToken, ClientError>
pub async fn exchange( &self, request: &ExchangeRequest, ) -> Result<ExchangedToken, ClientError>
Exchanges request for a new token. Not cached: the token belongs
to one principal and one downstream agent.
§Errors
The identity provider’s refusal (RFC 6749 §5.2 error, never the
tokens), a timeout, a transport failure, or a response without the
members §2.2.1 requires.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TokenExchange
impl !UnwindSafe for TokenExchange
impl Forget for TokenExchange
impl Freeze for TokenExchange
impl Move for TokenExchange
impl Send for TokenExchange
impl Sync for TokenExchange
impl Unpin for TokenExchange
impl UnsafeUnpin for TokenExchange
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].