auth: serialize exp and iat claims as NumericDate to comply with RFC7519 (#1289)

Add `jti` claim to the JWT to avoid hashing collisions
This commit is contained in:
psentee
2025-09-15 17:24:59 +02:00
committed by GitHub
parent 85ce481e32
commit 4590463cdf
5 changed files with 78 additions and 24 deletions

View File

@@ -136,7 +136,7 @@ features = ["full"]
version = "1.25"
[dependencies.uuid]
features = ["v1", "v3"]
features = ["v1", "v3", "v4"]
version = "1"
[dependencies.tracing-forest]

View File

@@ -35,6 +35,7 @@ use std::{
};
use time::ext::NumericalDuration;
use tracing::{debug, info, instrument, warn};
use uuid::Uuid;
type Token<S> = jwt::Token<jwt::Header, JWTClaims, S>;
type SignedToken = Token<jwt::token::Signed>;
@@ -56,6 +57,7 @@ async fn create_jwt<Handler: TcpBackendHandler>(
let claims = JWTClaims {
exp: Utc::now() + chrono::Duration::days(1),
iat: Utc::now(),
jti: Uuid::new_v4(),
user: user.to_string(),
groups: groups
.into_iter()