#[non_exhaustive]pub struct OidcConfig { /* private fields */ }Expand description
OIDC client-credentials configuration for a token endpoint.
Construct with OidcConfig::new; #[non_exhaustive] so fields can be
added without a breaking change.
Implementations§
Source§impl OidcConfig
impl OidcConfig
Sourcepub fn new(
token_url: impl Into<String>,
client_id: impl Into<String>,
client_secret: impl Into<String>,
) -> Self
pub fn new( token_url: impl Into<String>, client_id: impl Into<String>, client_secret: impl Into<String>, ) -> Self
Create a client-credentials configuration (no scope).
Sourcepub fn with_scope(self, scope: impl Into<String>) -> Self
pub fn with_scope(self, scope: impl Into<String>) -> Self
Set the OAuth2 scope.
Sourcepub fn with_client_auth(self, client_auth: ClientAuth) -> Self
pub fn with_client_auth(self, client_auth: ClientAuth) -> Self
Choose how the client credentials are presented (ClientAuth).
The provider presets set this themselves; reach for it when pointing
OidcConfig::new at an endpoint that wants the other form.
Sourcepub fn with_audience(self, audience: impl Into<String>) -> Self
pub fn with_audience(self, audience: impl Into<String>) -> Self
Set the audience parameter of the token request — the API the token
is being requested for.
Auth0 requires it (without one it issues an opaque token for its own userinfo endpoint, which a participant cannot verify). Most other providers ignore it.
Sourcepub fn client_auth(&self) -> ClientAuth
pub fn client_auth(&self) -> ClientAuth
How the client credentials are presented to the token endpoint.
Sourcepub fn audience(&self) -> Option<&str>
pub fn audience(&self) -> Option<&str>
The audience this configuration requests a token for, if any.
Sourcepub fn keycloak(
base_url: impl AsRef<str>,
realm: impl AsRef<str>,
client_id: impl Into<String>,
client_secret: impl Into<String>,
) -> Self
pub fn keycloak( base_url: impl AsRef<str>, realm: impl AsRef<str>, client_id: impl Into<String>, client_secret: impl Into<String>, ) -> Self
Preset for Keycloak (also the Canton LocalNet IdP): builds the
{base_url}/realms/{realm}/protocol/openid-connect/token endpoint.
Sourcepub fn auth0(
domain: impl AsRef<str>,
audience: impl Into<String>,
client_id: impl Into<String>,
client_secret: impl Into<String>,
) -> Self
pub fn auth0( domain: impl AsRef<str>, audience: impl Into<String>, client_id: impl Into<String>, client_secret: impl Into<String>, ) -> Self
Preset for Auth0: builds the https://{domain}/oauth/token
endpoint and requests a token for audience.
The audience is the identifier of the Auth0 API the participant validates against — it cannot be derived from the domain, and Auth0 answers a client-credentials request without one by issuing a token for its own userinfo endpoint, which the participant will reject. Asking for it here is what makes this preset produce Auth0’s normal request.
Sourcepub fn okta(
domain: impl AsRef<str>,
auth_server: impl AsRef<str>,
client_id: impl Into<String>,
client_secret: impl Into<String>,
) -> Self
pub fn okta( domain: impl AsRef<str>, auth_server: impl AsRef<str>, client_id: impl Into<String>, client_secret: impl Into<String>, ) -> Self
Preset for Okta: builds the
https://{domain}/oauth2/{auth_server}/v1/token endpoint (use
"default" for the default authorization server) and presents the
credentials as HTTP Basic, which is Okta’s default for a confidential
client.
An Okta app can be configured to accept them in the body instead; say
so with .with_client_auth(ClientAuth::Post).
Trait Implementations§
Source§impl Clone for OidcConfig
impl Clone for OidcConfig
Source§fn clone(&self) -> OidcConfig
fn clone(&self) -> OidcConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for OidcConfig
impl RefUnwindSafe for OidcConfig
impl Send for OidcConfig
impl Sync for OidcConfig
impl Unpin for OidcConfig
impl UnsafeUnpin for OidcConfig
impl UnwindSafe for OidcConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request