fix: better JWT cookie management
This commit is contained in:
parent
d70d622e04
commit
b20c30048c
12 changed files with 47 additions and 40 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue