OpenIdConnectMiddleware

Struct OpenIdConnectMiddleware 

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

Open ID Connect Middleware.

Implementations§

Source§

impl OpenIdConnectMiddleware

Source

pub async fn new(config: &Config) -> Self

Create a new instance.

Requests the Identity Provider’s metadata and uses that to initialize various provider-specific configuration inside of the middleware.

§Panics

Panics if the OpenID Connect provider metadata could not be retrieved or does not match the configured issuer_url.

§Defaults

The defaults for OpenIdConnectMiddleware are:

  • redirect strategy: HttpRedirect
  • login path: /login
  • scopes: ["openid"]
  • login landing path: /
  • logout path: /logout
  • logout destroys session: true
  • logout landing path: /
§Examples
use tide_openidconnect::{self};

let config = tide_openidconnect::Config {
    // ... set/load config ...
};
let middleware = tide_openidconnect::OpenIdConnectMiddleware::new(&config)
    .await
    .with_logout_landing_path("/loggedout");
Source

pub fn with_login_path(self, login_path: &str) -> Self

Sets the path to the “login” route that will be intercepted by the middleware in order to redirect the browser to the OpenID Connect authentication page.

Defaults to /login

Source

pub fn with_scopes(self, scopes: &[impl AsRef<str>]) -> Self

Adds one or more scopes to the OpenID Connect request.

Defaults to openid (which is the minimum required scope).

Source

pub fn with_login_landing_path(self, login_landing_path: &str) -> Self

Sets the path where the browser will be sent after a successful login sequence.

Defaults to /

Source

pub fn with_logout_path(self, logout_path: &str) -> Self

Sets the path to the “logout” route that will be intercepted by the middleware in order to clear the sessions’s authentication state.

Defaults to /logout

Source

pub fn with_logout_destroys_session(self, logout_destroys_session: bool) -> Self

Sets a flag indicating if the logout URL should destroy all session state – both the auth state and any app-level state – or if logout should clear only the auth state and leave the remainder of the state intact.

Applications should only retain session state after a logout if doing so will not leave any (private) artifacts of the user’s data in the session after the logout process. The current page, status of collapsed UI elements, etc. would be safe to retain, whereas the user name, form content, etc. needs to be cleared after the logout process (which can be done by, for example, configuring the logout_landing_path to go to a route that cleans up personally-identifying information after the logout completes).

Defaults to true

Source

pub fn with_logout_landing_path(self, logout_landing_path: &str) -> Self

Sets the path where the browser will be sent after the logout sequence.

Defaults to /

Source

pub fn with_unauthenticated_redirect_strategy<R>( self, redirect_strategy: R, ) -> Self
where R: RedirectStrategy + 'static,

Sets the trait used to generate redirect responses to unauthenticated requests.

Defaults to HttpRedirect

Trait Implementations§

Source§

impl Debug for OpenIdConnectMiddleware

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<State> Middleware<State> for OpenIdConnectMiddleware
where State: Clone + Send + Sync + 'static,

Source§

fn handle<'life0, 'life1, 'async_trait>( &'life0 self, req: Request<State>, next: Next<'life1, State>, ) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Asynchronously handle the request, and return a response.
Source§

fn name(&self) -> &str

Set the middleware’s name. By default it uses the type signature.

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<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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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
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
Source§

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