Files
axum-tower-sessions-edge/src/credentials/jwt.rs
geoffsee 958d9a19df init
2025-05-11 17:04:52 -04:00

25 lines
582 B
Rust

use serde::Serialize;
#[derive(Debug, Serialize)]
pub(super) struct JwtClaims {
iss: String,
sub: String,
iat: i64,
exp: i64,
aud: String,
}
impl JwtClaims {
pub(super) fn new(sub_and_iss: &str, audience: &str) -> Self {
let iat = time::OffsetDateTime::now_utc();
let exp = iat + time::Duration::hours(1);
Self {
iss: sub_and_iss.to_string(),
sub: sub_and_iss.to_string(),
iat: iat.unix_timestamp(),
exp: exp.unix_timestamp(),
aud: audience.to_string(),
}
}
}