Let expire the user cookie more quickly

This will hopefully fix the OIDC issue by causing the backend
to refresh the token more frequently.
This commit is contained in:
Simon Goller 2024-06-12 07:59:51 +02:00
parent e1f9936b62
commit 20a5f5859b

View file

@ -28,6 +28,8 @@ use service::PermissionService;
use service::ServiceError; use service::ServiceError;
use thiserror::Error; use thiserror::Error;
#[cfg(feature = "oidc")] #[cfg(feature = "oidc")]
use time::Duration;
#[cfg(feature = "oidc")]
use tower::ServiceBuilder; use tower::ServiceBuilder;
#[cfg(feature = "oidc")] #[cfg(feature = "oidc")]
use tower_sessions::MemoryStore; use tower_sessions::MemoryStore;
@ -308,7 +310,7 @@ pub async fn start_server<RestState: RestStateDef>(rest_state: RestState) {
let session_layer = SessionManagerLayer::new(session_store) let session_layer = SessionManagerLayer::new(session_store)
.with_secure(true) .with_secure(true)
.with_same_site(SameSite::Strict) .with_same_site(SameSite::Strict)
.with_expiry(Expiry::OnSessionEnd); .with_expiry(Expiry::OnInactivity(Duration::minutes(2)));
let oidc_auth_service = ServiceBuilder::new() let oidc_auth_service = ServiceBuilder::new()
.layer(HandleErrorLayer::new(|e: MiddlewareError| async { .layer(HandleErrorLayer::new(|e: MiddlewareError| async {