pub struct OidcProvider { /* private fields */ }Expand description
OpenID Connect Provider.
This extends the OAuth server with OIDC identity features.
Implementations§
Source§impl OidcProvider
impl OidcProvider
Sourcepub fn new(
oauth: Arc<OAuthServer>,
config: OidcProviderConfig,
) -> Result<OidcProvider, OidcError>
pub fn new( oauth: Arc<OAuthServer>, config: OidcProviderConfig, ) -> Result<OidcProvider, OidcError>
Creates a new OIDC provider with the given OAuth server.
Sourcepub fn with_defaults(oauth: Arc<OAuthServer>) -> Result<OidcProvider, OidcError>
pub fn with_defaults(oauth: Arc<OAuthServer>) -> Result<OidcProvider, OidcError>
Creates a new OIDC provider with default configuration.
Sourcepub fn config(&self) -> &OidcProviderConfig
pub fn config(&self) -> &OidcProviderConfig
Returns the OIDC configuration.
Sourcepub fn oauth(&self) -> &Arc<OAuthServer> ⓘ
pub fn oauth(&self) -> &Arc<OAuthServer> ⓘ
Returns a reference to the underlying OAuth server.
Sourcepub fn set_hmac_key(&self, key: impl AsRef<[u8]>)
pub fn set_hmac_key(&self, key: impl AsRef<[u8]>)
Sets the HMAC signing key.
Sourcepub fn set_claims_provider<P>(&self, provider: P)where
P: ClaimsProvider + 'static,
pub fn set_claims_provider<P>(&self, provider: P)where
P: ClaimsProvider + 'static,
Sets the claims provider.
Sourcepub fn set_claims_fn<F>(&self, func: F)
pub fn set_claims_fn<F>(&self, func: F)
Sets a function-based claims provider.
Sourcepub fn discovery_document(
&self,
base_url: impl Into<String>,
) -> DiscoveryDocument
pub fn discovery_document( &self, base_url: impl Into<String>, ) -> DiscoveryDocument
Generates the discovery document.
Sourcepub fn jwks(&self) -> Option<Value>
pub fn jwks(&self) -> Option<Value>
Returns the configured JSON Web Key Set (JWKS), if any.
For HS256 this is typically None. For RS256 it is required and should be served at
/.well-known/jwks.json alongside the discovery document.
Sourcepub fn issue_id_token(
&self,
access_token: &OAuthToken,
nonce: Option<&str>,
) -> Result<IdToken, OidcError>
pub fn issue_id_token( &self, access_token: &OAuthToken, nonce: Option<&str>, ) -> Result<IdToken, OidcError>
Issues an ID token for the given access token.
This should be called after a successful token exchange when the
openid scope was requested.
Sourcepub fn get_id_token(&self, access_token: &str) -> Option<IdToken>
pub fn get_id_token(&self, access_token: &str) -> Option<IdToken>
Gets the ID token associated with an access token.
Sourcepub fn userinfo(&self, access_token: &str) -> Result<UserClaims, OidcError>
pub fn userinfo(&self, access_token: &str) -> Result<UserClaims, OidcError>
Handles a userinfo request.
Returns the user’s claims filtered by the access token’s scopes.
Sourcepub fn cleanup_expired(&self)
pub fn cleanup_expired(&self)
Removes expired ID tokens from cache.
Auto Trait Implementations§
impl !Freeze for OidcProvider
impl RefUnwindSafe for OidcProvider
impl Send for OidcProvider
impl Sync for OidcProvider
impl Unpin for OidcProvider
impl UnsafeUnpin for OidcProvider
impl UnwindSafe for OidcProvider
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: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
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