Skip to main content

OidcProvider

Struct OidcProvider 

Source
pub struct OidcProvider { /* private fields */ }
Expand description

One OpenID Connect provider a panel signs users in through, installed with Oidc::provider.

OidcProvider::google is Google. OidcProvider::new is any other provider that publishes a discovery document at {issuer}/.well-known/openid-configuration and returns its ID token from the token endpoint: the panel reads the endpoints from that document on the first sign-in and keeps them.

The panel registers {base_url}{prefix}/sign-in/{key}/callback as its redirect URI, where base_url is Oidc::new’s; register the same URI with the provider.

The panel authenticates to the token endpoint with HTTP Basic (client_secret_basic), which every provider supports. A multi-tenant issuer whose discovery document names a placeholder issuer, such as Microsoft’s common endpoint, fails the discovery check: name the tenant’s own issuer instead.

Implementations§

Source§

impl OidcProvider

Source

pub fn google( client_id: impl Into<String>, client_secret: impl Into<String>, ) -> Self

Google, signing in the client client_id with client_secret from a Google Cloud project’s OAuth client of the “Web application” type. Its key is google, so its redirect URI is {base_url}{prefix}/sign-in/google/callback.

Source

pub fn new( key: impl Into<String>, label: impl Into<Text>, issuer: impl Into<String>, client_id: impl Into<String>, client_secret: impl Into<String>, ) -> Self

The provider whose issuer is issuer, such as https://login.example.com, signing in the client client_id with client_secret. key names it in its routes, such as okta: lowercase ASCII letters, digits and -. label is the name its button shows.

issuer is an https URL, or an http one on a loopback host for a provider running on the same machine; anything else is a declaration error. It is spelled exactly as the provider’s ID tokens carry it, trailing / included where the provider writes one.

Source

pub fn scope(self, scope: impl Into<String>) -> Self

Also asks for scope, beyond openid email profile.

Source

pub fn param(self, name: impl Into<String>, value: impl Into<String>) -> Self

Sends name=value with every authorization request, such as Google’s .param("prompt", "select_account"), or .param("hd", "example.com") to offer the accounts of one Workspace domain. A parameter only shapes the provider’s page: a linker that admits one domain alone checks the identity’s hd claim itself. Naming a parameter the panel sets, such as state or redirect_uri, is a declaration error.

Trait Implementations§

Source§

impl Debug for OidcProvider

Redacts the client secret, so a provider logged with ? writes none to the log.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more