Struct AuthorityBuilder

Source
pub struct AuthorityBuilder<Claims, Algo, ReAuth, Args>
where Algo: Algorithm + Clone, Algo::SigningKey: Clone,
{ /* private fields */ }
Expand description

Builder for Authority.

Implementations§

Source§

impl<Claims, Algo, ReAuth, Args> AuthorityBuilder<Claims, Algo, ReAuth, Args>
where Algo: Algorithm + Clone, Algo::SigningKey: Clone,

Source

pub fn refresh_authorizer(self, value: ReAuth) -> Self

The refresh_authorizer is called every time, when a client with an expired access token but a valid refresh token tries to fetch a resource protected by the JWT middleware.

By returning the Ok variant your grand the client permission to get a new access token. In contrast, by returning the Err variant you deny the request. The actix_web::Error returned in this case will be passed along as a wrapped AuthError::RefreshAuthorizerDenied back to the client (There are options to remap this, for example this crate: actix-error-mapper-middleware).

Since refresh_authorizer has to implement the Handler trait, you are able to access your regular application an request state from within the function. This allows you to perform Database Check etc…

Source

pub fn access_token_name<VALUE: Into<String>>(self, value: VALUE) -> Self

Depending on whether a TokenSigner is set, setting this field will have no affect.

Defaults to the value of the access_token_name field set on the token_signer, if the token_signer is not set, this defaults to "access_token".

Source

pub fn renew_access_token_automatically(self, value: bool) -> Self

If set to false the clients access token will not be automatically refreshed.

Defaults to true

Source

pub fn refresh_token_name<VALUE: Into<String>>(self, value: VALUE) -> Self

Depending on whether a TokenSigner is set, setting this field will have no affect.

Defaults to the value of the refresh_token_name field set on the token_signer, if the token_signer is not set, this defaults to "refresh_token".

Source

pub fn renew_refresh_token_automatically(self, value: bool) -> Self

If set to true the clients refresh token will automatically refreshed, this allows clients to basically stay authenticated over a infinite amount of time, so i don’t recommend it.

Defaults to false

Source

pub fn enable_header_tokens(self, value: bool) -> Self

If set to true, the service will look for access_token_name and refresh_token_name in http headers.

Source

pub fn enable_authorization_header(self, value: bool) -> Self

If set to true, the service will look for the Authorization header in the http headers.

Source

pub fn enable_query_tokens(self, value: bool) -> Self

If set to true, the service will look for access_token_name and refresh_token_name in in the query parameters.

If set to true, the service will look for access_token_name and refresh_token_name in in the cookies of the processed request.

Source

pub fn verifying_key(self, value: Algo::VerifyingKey) -> Self

Key used to verify integrity of access and refresh token.

Source

pub fn algorithm(self, value: Algo) -> Self

The Cryptographic signing algorithm used in the process of creation of access and refresh tokens.

Please referee to the Supported algorithms section of the jwt-compact crate for a comprehensive list of the supported algorithms.

Defaults to the value of the algorithm field set on the token_signer, if the token_signer is not set, this field needs to be set.

Source

pub fn time_options(self, value: TimeOptions) -> Self

Used in the creating of the token, the current time stamp is taken from this, but please referee to the Structs documentation.

Defaults to the value of the time_options field set on the token_signer, if the token_signer is not set, this field needs to be set.

Source

pub fn token_signer(self, value: Option<TokenSigner<Claims, Algo>>) -> Self

Not Passing a TokenSigner struct will make your middleware unable to refresh the access token automatically.

You will have to provide a algorithm manually in this case because the Authority can not pull it from the token_signer field.

Please referee to the structs own documentation for more details.

Source

pub fn build( self, ) -> Result<Authority<Claims, Algo, ReAuth, Args>, AuthorityBuilderError>

Builds a new Authority.

§Errors

If a required field has not been initialized.

Trait Implementations§

Source§

impl<Claims, Algo, ReAuth, Args> Default for AuthorityBuilder<Claims, Algo, ReAuth, Args>
where Algo: Algorithm + Clone, Algo::SigningKey: Clone,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Claims, Algo, ReAuth, Args> Freeze for AuthorityBuilder<Claims, Algo, ReAuth, Args>
where <Algo as Algorithm>::SigningKey: Sized + Freeze, ReAuth: Freeze, <Algo as Algorithm>::VerifyingKey: Freeze, Algo: Freeze,

§

impl<Claims, Algo, ReAuth, Args> RefUnwindSafe for AuthorityBuilder<Claims, Algo, ReAuth, Args>

§

impl<Claims, Algo, ReAuth, Args> Send for AuthorityBuilder<Claims, Algo, ReAuth, Args>
where <Algo as Algorithm>::SigningKey: Sized + Send, ReAuth: Send, <Algo as Algorithm>::VerifyingKey: Send, Algo: Send, Claims: Send, Args: Send,

§

impl<Claims, Algo, ReAuth, Args> Sync for AuthorityBuilder<Claims, Algo, ReAuth, Args>
where <Algo as Algorithm>::SigningKey: Sized + Sync, ReAuth: Sync, <Algo as Algorithm>::VerifyingKey: Sync, Algo: Sync, Claims: Sync, Args: Sync,

§

impl<Claims, Algo, ReAuth, Args> Unpin for AuthorityBuilder<Claims, Algo, ReAuth, Args>
where <Algo as Algorithm>::SigningKey: Sized + Unpin, ReAuth: Unpin, <Algo as Algorithm>::VerifyingKey: Unpin, Algo: Unpin, Claims: Unpin, Args: Unpin,

§

impl<Claims, Algo, ReAuth, Args> UnwindSafe for AuthorityBuilder<Claims, Algo, ReAuth, Args>
where <Algo as Algorithm>::SigningKey: Sized + UnwindSafe, ReAuth: UnwindSafe, <Algo as Algorithm>::VerifyingKey: UnwindSafe, Algo: UnwindSafe, Claims: UnwindSafe, Args: UnwindSafe,

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, 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> 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> ErasedDestructor for T
where T: 'static,