pub struct OidcClient { /* private fields */ }Expand description
One configured OIDC provider at runtime: config + HTTP client +
cached discovery document. The introspection cache lives on the
dataplane (OidcIntrospectionCache) so a config reload reuses
cached results.
Implementations§
Source§impl OidcClient
impl OidcClient
Sourcepub fn build(cfg: OidcProvider) -> Result<Arc<Self>, OidcError>
pub fn build(cfg: OidcProvider) -> Result<Arc<Self>, OidcError>
Build the runtime client from config. The trusted_ca_file is
loaded here (at build time) so a broken bundle disables this
provider at build instead of failing every request.
Sourcepub fn config(&self) -> &OidcProvider
pub fn config(&self) -> &OidcProvider
The resolved config (for validation / introspection).
The authorization endpoint URL (for the auth-code flow): from the discovery document.
Sourcepub async fn introspect(
&self,
token: &str,
cache: &OidcIntrospectionCache,
) -> Result<IntrospectionResponse, OidcError>
pub async fn introspect( &self, token: &str, cache: &OidcIntrospectionCache, ) -> Result<IntrospectionResponse, OidcError>
Introspect a bearer token (RFC 7662). Returns the parsed
introspection response. The caller is responsible for caching
(via OidcIntrospectionCache) and fail-open/fail-closed
mapping. Client auth is HTTP Basic (RFC 7662 section 2.1);
the token is sent as token in the form-encoded body.
Sourcepub async fn revoke(
&self,
token: &str,
cache: &OidcIntrospectionCache,
) -> Result<(), OidcError>
pub async fn revoke( &self, token: &str, cache: &OidcIntrospectionCache, ) -> Result<(), OidcError>
Revoke a token (RFC 7009). POST to the revocation endpoint with
the token. This is an admin/management operation, not on the hot
request path. The introspection cache entry for this token is
invalidated so the next request re-introspects (or fails 401).
Returns Ok(()) on a 2xx response; the RFC notes a 200 is the
success response and a 400 may indicate an unrecognized token
(treated as an error here so the caller can report it).
Sourcepub async fn exchange_token(
&self,
subject_token: &str,
audience: &str,
) -> Result<String, OidcError>
pub async fn exchange_token( &self, subject_token: &str, audience: &str, ) -> Result<String, OidcError>
Token exchange (RFC 8693): exchange a subject token for an
actor token. The subject token is the client’s bearer token
(subject_token); the actor token is what the gateway forwards
to the upstream. audience is the resource server the actor
token is intended for (RFC 8693 section 2.1). Returns the actor
token string on success.
Sourcepub async fn exchange_code(
&self,
code: &str,
redirect_uri: &str,
code_verifier: &str,
) -> Result<TokenSet, OidcError>
pub async fn exchange_code( &self, code: &str, redirect_uri: &str, code_verifier: &str, ) -> Result<TokenSet, OidcError>
Exchange an authorization code for tokens (RFC 6749 section 4.1,
the auth-code + PKCE flow). code is the authorization code
from the IdP’s callback redirect; redirect_uri is the
gateway’s callback URL; code_verifier is the PKCE verifier
matching the challenge sent in the authorization request. Returns
the parsed token response (access, refresh, ID token, etc.).
Build the authorization request URL for the auth-code + PKCE
flow (RFC 6749 section 4.1.1 + RFC 7636). The gateway redirects
the user agent to this URL; the IdP authenticates the user and
redirects back to redirect_uri with an authorization code.
state is an opaque value the gateway round-trips for CSRF
protection; code_challenge is the PKCE challenge derived from
code_verifier (S256: base64url(sha256(verifier))).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for OidcClient
impl !RefUnwindSafe for OidcClient
impl Send for OidcClient
impl Sync for OidcClient
impl Unpin for OidcClient
impl !UnwindSafe for OidcClient
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§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<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§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