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<Self, OidcError>
pub fn new( oauth: Arc<OAuthServer>, config: OidcProviderConfig, ) -> Result<Self, OidcError>
Creates a new OIDC provider with the given OAuth server.
Sourcepub fn with_defaults(oauth: Arc<OAuthServer>) -> Result<Self, OidcError>
pub fn with_defaults(oauth: Arc<OAuthServer>) -> Result<Self, 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: ClaimsProvider + 'static>(&self, provider: P)
pub fn set_claims_provider<P: ClaimsProvider + 'static>(&self, provider: P)
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.