Skip to content

Commit

Permalink
Parse exp from JWT (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton authored Dec 7, 2023
1 parent a4bf99b commit 5cf658d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/bitwarden/src/auth/jwt_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub organization: Option<String>,
Expand Down Expand Up @@ -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("[email protected]"));
assert_eq!(token.organization.as_deref(), None);
Expand Down

0 comments on commit 5cf658d

Please sign in to comment.