pub struct OidcClient { /* private fields */ }Expand description
A single discovered upstream — wraps the openidconnect typed
client and the PoD metadata used to construct it.
The CoreClient generic state after from_provider_metadata + set_redirect_uri is <EndpointSet, EndpointNotSet, EndpointNotSet, EndpointNotSet, EndpointMaybeSet, EndpointMaybeSet> — auth URL set
(so authorize_url works), token + userinfo MaybeSet (we error at
runtime if the upstream’s discovery doc is missing one).
Implementations§
Source§impl OidcClient
impl OidcClient
Sourcepub fn provider(&self) -> &UpstreamProvider
pub fn provider(&self) -> &UpstreamProvider
Borrow the original PoD record.
Sourcepub fn redirect_uri(&self) -> &RedirectUrl
pub fn redirect_uri(&self) -> &RedirectUrl
Borrow the configured redirect URI.
Sourcepub fn start_login(&self, state: CsrfToken) -> StartedLogin
pub fn start_login(&self, state: CsrfToken) -> StartedLogin
Step 1 of the authorization-code-+-PKCE flow. Generates a PKCE
pair, asks the openidconnect client for the redirect URL,
returns the URL alongside the verifier + nonce for round-trip
(callers persist them, typically in the session).
state lets callers pin a known CSRF value (e.g. the session id)
rather than the library-generated random one — useful when the
callback handler uses state to look the in-progress login up.
Pass CsrfToken::new_random via CsrfToken::new(...) if you
don’t have one already.
Sourcepub async fn complete_login(
&self,
code: String,
pkce_verifier: PkceCodeVerifier,
nonce: Nonce,
) -> Result<UpstreamUserInfo>
pub async fn complete_login( &self, code: String, pkce_verifier: PkceCodeVerifier, nonce: Nonce, ) -> Result<UpstreamUserInfo>
Step 2 — exchange the upstream’s code for tokens, validate the
id_token against the cached JWKS + nonce, and (when the upstream
publishes a userinfo endpoint) supplement the claims with a
userinfo call.
pkce_verifier and nonce must be the values returned from
OidcClient::start_login for the same login — callers persist
them server-side keyed by state.
Auto Trait Implementations§
impl Freeze for OidcClient
impl RefUnwindSafe for OidcClient
impl Send for OidcClient
impl Sync for OidcClient
impl Unpin for OidcClient
impl UnsafeUnpin for OidcClient
impl UnwindSafe for OidcClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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
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