From e749a685cd26357eea114eb8d902454da2beb07b Mon Sep 17 00:00:00 2001 From: nazeh Date: Fri, 11 Oct 2024 16:31:12 +0300 Subject: [PATCH] feat(homeserver): set session cookies expiration date to two years --- pubky-homeserver/src/routes/auth.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pubky-homeserver/src/routes/auth.rs b/pubky-homeserver/src/routes/auth.rs index a4f36fc..034d29c 100644 --- a/pubky-homeserver/src/routes/auth.rs +++ b/pubky-homeserver/src/routes/auth.rs @@ -6,7 +6,13 @@ use axum::{ }; use axum_extra::{headers::UserAgent, TypedHeader}; use bytes::Bytes; -use tower_cookies::{cookie::SameSite, Cookie, Cookies}; +use tower_cookies::{ + cookie::{ + time::{Duration, OffsetDateTime}, + SameSite, + }, + Cookie, Cookies, +}; use pubky_common::{crypto::random_bytes, session::Session, timestamp::Timestamp}; @@ -124,6 +130,7 @@ pub async fn signin( let mut cookie = Cookie::new(public_key.to_string(), session_secret); cookie.set_path("/"); + cookie.set_expires(OffsetDateTime::now_utc() + Duration::weeks(104)); if is_secure(&host) { cookie.set_secure(true);