From 5cf658daf4057da469f4035bc5dd5269270e2a7d Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 7 Dec 2023 17:54:58 +0100 Subject: [PATCH] Parse exp from JWT (#406) --- crates/bitwarden/src/auth/jwt_token.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/bitwarden/src/auth/jwt_token.rs b/crates/bitwarden/src/auth/jwt_token.rs index 14cbaf84f..9097b84f2 100644 --- a/crates/bitwarden/src/auth/jwt_token.rs +++ b/crates/bitwarden/src/auth/jwt_token.rs @@ -13,6 +13,7 @@ use crate::{error::Result, util::BASE64_ENGINE}; /// TODO: We need to expand this to support user based JWT tokens. #[derive(serde::Deserialize)] pub struct JWTToken { + pub exp: u64, pub sub: String, pub email: Option, pub organization: Option, @@ -62,6 +63,7 @@ mod tests { f3LEddAPV8cAFza4DjA8pZJLFrMyRvMXcL_PjKF8qPVzqVWh03lfJ4clOIxR2gOuWIc902Y5E"; let token: JWTToken = jwt.parse().unwrap(); + assert_eq!(token.exp, 1675107177); assert_eq!(token.sub, "e25d37f3-b603-40de-84ba-af96012f5a42"); assert_eq!(token.email.as_deref(), Some("test@bitwarden.com")); assert_eq!(token.organization.as_deref(), None);