[−][src]Struct rocket_oauth2::OAuth2
The OAuth2
structure implements OAuth in a Rocket application by setting
up OAuth-related route handlers.
Redirect handler
OAuth2
handles the redirect URI. It verifies the state
token to prevent
CSRF attacks, then instructs the Adapter to perform the token exchange. The
resulting token is passed to the Callback
.
Login handler
OAuth2
optionally handles a login route, which simply redirects to the
authorization URI generated by the Adapter
. Whether or not OAuth2
is
handling a login URI, get_redirect
can be used to get a Redirect
to the
OAuth login flow manually.
Methods
impl<C: Callback> OAuth2<C>
[src]
pub fn fairing<A: Adapter>(
adapter: A,
callback: C,
config_name: &str,
callback_uri: &str,
login: Option<(&str, Vec<String>)>
) -> impl Fairing
[src]
adapter: A,
callback: C,
config_name: &str,
callback_uri: &str,
login: Option<(&str, Vec<String>)>
) -> impl Fairing
Returns an OAuth2 fairing. The fairing will place an instance of
OAuth2<C>
in managed state and mount a redirect handler. It will
also mount a login handler if login
is Some
.
pub fn custom<A: Adapter>(
adapter: A,
callback: C,
config: OAuthConfig,
callback_uri: &str,
login: Option<(&str, Vec<String>)>
) -> impl Fairing
[src]
adapter: A,
callback: C,
config: OAuthConfig,
callback_uri: &str,
login: Option<(&str, Vec<String>)>
) -> impl Fairing
Returns an OAuth2 fairing with custom configuration. The fairing will
place an instance of OAuth2<C>
in managed state and mount a
redirect handler. It will also mount a login handler if login
is
Some
.
pub fn get_redirect(
&self,
cookies: &mut Cookies,
scopes: &[&str]
) -> Result<Redirect, Error>
[src]
&self,
cookies: &mut Cookies,
scopes: &[&str]
) -> Result<Redirect, Error>
Prepare an authentication redirect. This sets a state cookie and returns
a Redirect
to the provider's authorization page.
pub fn refresh(&self, refresh_token: &str) -> Result<TokenResponse, Error>
[src]
Request a new access token given a refresh token. The refresh token
must have been returned by the provider in a previous TokenResponse
.
Trait Implementations
Auto Trait Implementations
impl<C> !RefUnwindSafe for OAuth2<C>
impl<C> Send for OAuth2<C> where
C: Send,
C: Send,
impl<C> Sync for OAuth2<C> where
C: Sync,
C: Sync,
impl<C> Unpin for OAuth2<C> where
C: Unpin,
C: Unpin,
impl<C> !UnwindSafe for OAuth2<C>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, I> AsResult<T, I> for T where
I: Input,
I: Input,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
A: Array<Item = T>,
fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
A: Array<Item = U>,
F: FnMut(T) -> U,
A: Array<Item = U>,
F: FnMut(T) -> U,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Typeable for T where
T: Any,
T: Any,