This commit is contained in:
geoffsee
2025-05-11 17:04:52 -04:00
commit 958d9a19df
36 changed files with 7161 additions and 0 deletions

24
src/credentials/jwt.rs Normal file
View File

@@ -0,0 +1,24 @@
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(),
}
}
}