Add missing claim

This commit is contained in:
Pierre HUBERT 2022-04-13 19:14:37 +02:00
parent 53a540139c
commit 8a005c4185

View File

@ -25,8 +25,13 @@ pub struct IdToken {
pub nonce: Option<String>, pub nonce: Option<String>,
} }
#[derive(serde::Serialize, serde::Deserialize)]
pub struct CustomIdTokenClaims {
auth_time: u64,
}
impl IdToken { impl IdToken {
pub fn to_jwt_claims(self) -> JWTClaims<()> { pub fn to_jwt_claims(self) -> JWTClaims<CustomIdTokenClaims> {
JWTClaims { JWTClaims {
issued_at: Some(Duration::from_secs(self.issued_at)), issued_at: Some(Duration::from_secs(self.issued_at)),
expires_at: Some(Duration::from_secs(self.expiration_time)), expires_at: Some(Duration::from_secs(self.expiration_time)),
@ -36,7 +41,9 @@ impl IdToken {
audiences: Some(Audiences::AsString(self.audience)), audiences: Some(Audiences::AsString(self.audience)),
jwt_id: None, jwt_id: None,
nonce: self.nonce, nonce: self.nonce,
custom: (), custom: CustomIdTokenClaims {
auth_time: self.auth_time
},
} }
} }
} }