init
This commit is contained in:
24
src/credentials/jwt.rs
Normal file
24
src/credentials/jwt.rs
Normal 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(),
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user