fix: better JWT cookie management

This commit is contained in:
Matthieu Bessat 2024-11-16 14:30:01 +01:00
parent d70d622e04
commit b20c30048c
12 changed files with 47 additions and 40 deletions

View file

@ -1,6 +1,7 @@
use fully_pub::fully_pub;
use jsonwebtoken::get_current_timestamp;
use serde::{Deserialize, Serialize};
use time::Duration;
use super::authorization::AuthorizationScope;
@ -17,10 +18,10 @@ struct UserTokenClaims {
}
impl UserTokenClaims {
pub fn from_user_id(user_id: &str) -> Self {
pub fn new(user_id: &str, max_age: Duration) -> Self {
UserTokenClaims {
sub: user_id.into(),
exp: get_current_timestamp() + 86_000,
exp: get_current_timestamp() + max_age.whole_seconds() as u64,
iss: "Minauthator".into()
}
}