OidcClient

Struct OidcClient 

Source
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

Source

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.

Source

pub fn config(&self) -> &OidcProvider

The resolved config (for validation / introspection).

Source

pub fn name(&self) -> &str

The provider’s name (a stable key for the introspection cache).

Source

pub async fn authorization_endpoint(&self) -> Result<String, OidcError>

The authorization endpoint URL (for the auth-code flow): from the discovery document.

Source

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.

Source

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).

Source

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.

Source

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.).

Source

pub async fn authorization_url( &self, redirect_uri: &str, state: &str, code_challenge: &str, ) -> Result<String, OidcError>

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§

Source§

impl Debug for OidcClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AnyExt for T
where T: Any + ?Sized,

§

fn downcast_ref<T>(this: &Self) -> Option<&T>
where T: Any,

Attempts to downcast this to T behind reference
§

fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>
where T: Any,

Attempts to downcast this to T behind mutable reference
§

fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Any,

Attempts to downcast this to T behind Rc pointer
§

fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Any,

Attempts to downcast this to T behind Arc pointer
§

fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Any,

Attempts to downcast this to T behind Box pointer
§

fn downcast_move<T>(this: Self) -> Option<T>
where T: Any, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, X> CoerceTo<T> for X
where 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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,