pub struct AuthConfig<Type>{
pub(crate) cache: bool,
pub(crate) anonymous_user_id: Option<Type>,
pub(crate) session_id: Cow<'static, str>,
pub(crate) max_age: Duration,
}
Expand description
Configuration for how the Auth service is used.
§Examples
use axum_session_auth::AuthConfig;
let config = AuthConfig::<i64>::default();
Fields§
§cache: bool
Allows caching of Users, Must tell the database to reload user when a change is made when cached.
anonymous_user_id: Option<Type>
The anonymous user id for logging unlogged users into a default guest like account. ID 0 is None
session_id: Cow<'static, str>
Session Id for the User ID storage.
max_age: Duration
Age the cache is allowed to live for if no visits are made.
Implementations§
Source§impl<Type> AuthConfig<Type>
impl<Type> AuthConfig<Type>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates Default
configuration of AuthConfig
.
This is equivalent to the AuthConfig::<i64>::default()
.
Sourcepub fn set_cache(self, cache: bool) -> Self
pub fn set_cache(self, cache: bool) -> Self
Sets the auth session to cache the users data for faster reload. if set to true and you update a users Data you must also trigger the reload of the user to reload the new changes on their next request.
§Examples
use axum_session_auth::AuthConfig;
let config = AuthConfig::<i64>::default().set_cache(true);
Sourcepub fn with_anonymous_user_id(self, id: Option<Type>) -> Self
pub fn with_anonymous_user_id(self, id: Option<Type>) -> Self
Set the auto logged in user ID if the user making the request is not logged in yet. Do not use ID 0 as this stands for the default Return when no user is loaded.
§Examples
use axum_session_auth::AuthConfig;
let config = AuthConfig::<i64>::default().with_anonymous_user_id(Some(0));
Sourcepub fn with_max_age(self, time: Duration) -> Self
pub fn with_max_age(self, time: Duration) -> Self
Set’s the auth session’s max_age (expiration time).
This is used to deturmine how long a User Account is cached per last request
§Examples
use axum_session_auth::AuthConfig;
use chrono::Duration;
let config = AuthConfig::<i64>::default().with_max_age(Some(Duration::days(2)));
Trait Implementations§
Source§impl<Type> Clone for AuthConfig<Type>
impl<Type> Clone for AuthConfig<Type>
Source§fn clone(&self) -> AuthConfig<Type>
fn clone(&self) -> AuthConfig<Type>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more