Skip to content

Commit

Permalink
feat(homeserver): set session cookies expiration date to two years
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuhvi committed Oct 11, 2024
1 parent fdfde60 commit e749a68
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pubky-homeserver/src/routes/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e749a68

Please sign in to comment.