pub struct OpenIdConnectMiddleware { /* private fields */ }
Expand description
Open ID Connect Middleware.
Implementations§
Source§impl OpenIdConnectMiddleware
impl OpenIdConnectMiddleware
Sourcepub async fn new(config: &Config) -> Self
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");
Sourcepub fn with_login_path(self, login_path: &str) -> Self
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
Sourcepub fn with_scopes(self, scopes: &[impl AsRef<str>]) -> Self
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).
Sourcepub fn with_login_landing_path(self, login_landing_path: &str) -> Self
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 /
Sourcepub fn with_logout_path(self, logout_path: &str) -> Self
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
Sourcepub fn with_logout_destroys_session(self, logout_destroys_session: bool) -> Self
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
Sourcepub fn with_logout_landing_path(self, logout_landing_path: &str) -> Self
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 /
Sourcepub fn with_unauthenticated_redirect_strategy<R>(
self,
redirect_strategy: R,
) -> Selfwhere
R: RedirectStrategy + 'static,
pub fn with_unauthenticated_redirect_strategy<R>(
self,
redirect_strategy: R,
) -> Selfwhere
R: RedirectStrategy + 'static,
Sets the trait used to generate redirect responses to unauthenticated requests.
Defaults to HttpRedirect
Trait Implementations§
Source§impl Debug for OpenIdConnectMiddleware
impl Debug for OpenIdConnectMiddleware
Source§impl<State> Middleware<State> for OpenIdConnectMiddleware
impl<State> Middleware<State> for OpenIdConnectMiddleware
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,
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,
Auto Trait Implementations§
impl Freeze for OpenIdConnectMiddleware
impl !RefUnwindSafe for OpenIdConnectMiddleware
impl Send for OpenIdConnectMiddleware
impl Sync for OpenIdConnectMiddleware
impl Unpin for OpenIdConnectMiddleware
impl !UnwindSafe for OpenIdConnectMiddleware
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: 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> 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