pub struct Config<T: Serialize + DeserializeOwned + Send + Sync, F: Fn(&str, &str, SocketAddr, &FatRequest) -> Fut + Send + Sync, Fut: Future<Output = Validation<T>> + Send + Sync> { /* private fields */ }
Expand description

The configured authentication. This can be attached to a Kvarn host using the Self::mount method. You can call Self::login_status to get a function to use in your extensions to check for authentication status.

Implementations

Returns a closure that can be sent to a Kvarn extension to extract the data from the user’s JWT and validating the authenticity of the client.

This makes it easier to cross the boundary of the Kvarn extension (using the move || semantics). See LoginStatusClosure.

If the closure returns Validation::Unauthorized, redirect the user to your login page (Builder::with_auth_page_name).

Create an API route at Builder::with_auth_page_name and make the JWT token automatically refresh.

To log in, use JavaScript’s fetch with method POST or PUT to the auth_page_name, with the username length on the first lines, then on the second line, the username concatenated with the password without any space. The rest of the body (after username length) is considered to be the password (it can contains newlines).

To log out, fetch DELETE to auth_page_name.

Panics

Panics if this config was created using Builder::build_validate.

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.

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 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.