pub struct OidcServerClient { /* private fields */ }Expand description
Minimal OIDC client for server-side PKCE code exchange.
Constructed once at server startup from the compiled schema. The client secret is read from the environment at that time and held in memory — it is never written to disk or emitted in logs.
Implementations§
Source§impl OidcServerClient
impl OidcServerClient
Sourcepub fn new(
client_id: impl Into<String>,
client_secret: impl Into<String>,
server_redirect_uri: impl Into<String>,
authorization_endpoint: impl Into<String>,
token_endpoint: impl Into<String>,
) -> Self
pub fn new( client_id: impl Into<String>, client_secret: impl Into<String>, server_redirect_uri: impl Into<String>, authorization_endpoint: impl Into<String>, token_endpoint: impl Into<String>, ) -> Self
Construct a client directly from resolved credentials and endpoints.
Prefer Self::from_compiled_schema in production code.
This constructor exists for testing and direct wiring.
Sourcepub fn from_compiled_schema(schema_json: &Value) -> Option<Arc<Self>>
pub fn from_compiled_schema(schema_json: &Value) -> Option<Arc<Self>>
Build an OidcServerClient from the compiled schema JSON.
Returns None if:
schema_json["auth"]is absent, or- the env var named by
client_secret_envis not set, or - the OIDC endpoint cache (
schema_json["auth_endpoints"]) is absent.
In all failure cases an explanatory tracing::error! is emitted so
operators can diagnose startup issues without reading source code.
Build the OIDC /authorize redirect URL with all required PKCE params.
The state, code_challenge, and redirect_uri values are
percent-encoded so that base64-url characters (+, /, =) do not
break query string parsing on the provider side.
Sourcepub async fn exchange_code(
&self,
code: &str,
code_verifier: &str,
http: &Client,
) -> Result<OidcTokenResponse, Error>
pub async fn exchange_code( &self, code: &str, code_verifier: &str, http: &Client, ) -> Result<OidcTokenResponse, Error>
Exchange an authorization code for tokens.
Sends a POST to the provider’s /token endpoint with the PKCE
code_verifier and all required OAuth2 fields.
§Errors
Returns an error if the HTTP request fails, the provider returns a
non-success status, the response exceeds MAX_OIDC_RESPONSE_BYTES, or
the response body cannot be parsed as JSON.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OidcServerClient
impl RefUnwindSafe for OidcServerClient
impl Send for OidcServerClient
impl Sync for OidcServerClient
impl Unpin for OidcServerClient
impl UnsafeUnpin for OidcServerClient
impl UnwindSafe for OidcServerClient
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> 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