pub struct AuthorityBuilder<Claims, Algo, ReAuth, Args>{ /* private fields */ }
Expand description
Builder for Authority
.
Implementations§
Source§impl<Claims, Algo, ReAuth, Args> AuthorityBuilder<Claims, Algo, ReAuth, Args>
impl<Claims, Algo, ReAuth, Args> AuthorityBuilder<Claims, Algo, ReAuth, Args>
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…
Sourcepub fn access_token_name<VALUE: Into<String>>(self, value: VALUE) -> Self
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"
.
Sourcepub fn renew_access_token_automatically(self, value: bool) -> Self
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
Sourcepub fn refresh_token_name<VALUE: Into<String>>(self, value: VALUE) -> Self
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"
.
Sourcepub fn renew_refresh_token_automatically(self, value: bool) -> Self
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
Sourcepub fn enable_header_tokens(self, value: bool) -> Self
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.
If set to true, the service will look for the Authorization
header in the http headers.
Sourcepub fn enable_query_tokens(self, value: bool) -> Self
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.
Sourcepub fn verifying_key(self, value: Algo::VerifyingKey) -> Self
pub fn verifying_key(self, value: Algo::VerifyingKey) -> Self
Key used to verify integrity of access and refresh token.
Sourcepub fn algorithm(self, value: Algo) -> Self
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.
Sourcepub fn time_options(self, value: TimeOptions) -> Self
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.
Sourcepub fn token_signer(self, value: Option<TokenSigner<Claims, Algo>>) -> Self
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.