pub struct AuthorityBuilder<Claims, Algorithm, RefreshAuthorizer, Args>where
    Algorithm: Algorithm,
    Algorithm::SigningKey: Clone,
    Algorithm::VerifyingKey: Clone,
{ /* private fields */ }
Expand description

Builder for Authority.

Implementations§

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 internal AuthError back to the client (There are options to remap this [actix-error-mapper]).

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…

Not Passing a CookieSigner 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 cookie_signer field.

Please referee to the structs own documentation for more details.

Depending on wether a CookieSigner is set, setting this field will have no affect.

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

Self explanatory, if set to false the clients access token will not be automatically refreshed.

Defaults to true

Depending on wether a CookieSigner is set, setting this field will have no affect.

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

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

Key used to verify integrity of access and refresh token.

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 cookie_signer, if the cookie_signer is not set, this field needs to be set.

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

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

Builds a new Authority.

Errors

If a required field has not been initialized.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more