Skip to content

Commit

Permalink
Change jwt parsing to use URL_SAFE_NO_PAD (#450)
Browse files Browse the repository at this point in the history
JWT should be url encoded and never use padding.
  • Loading branch information
Hinton authored Jan 5, 2024
1 parent 68236d3 commit 816799d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/bitwarden/src/auth/jwt_token.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::str::FromStr;

use base64::Engine;
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};

use crate::{error::Result, util::BASE64_ENGINE};
use crate::error::Result;

/// A Bitwarden secrets manager JWT Token.
///
Expand Down Expand Up @@ -31,7 +31,7 @@ impl FromStr for JWTToken {
if split.len() != 3 {
return Err("JWT token has an invalid number of parts".into());
}
let decoded = BASE64_ENGINE.decode(split[1])?;
let decoded = URL_SAFE_NO_PAD.decode(split[1])?;
Ok(serde_json::from_slice(&decoded)?)
}
}
Expand Down

0 comments on commit 816799d

Please sign in to comment.