From 62cebebd3d3f7d51d2a38afd36c4aa12a8bd088b Mon Sep 17 00:00:00 2001 From: Jeremy Lin Date: Mon, 27 Mar 2023 00:03:54 -0700 Subject: [PATCH] Decode knowndevice `X-Request-Email` as base64url with no padding The clients end up removing the padding characters [1][2]. [1] https://github.com/bitwarden/clients/blob/web-v2023.3.0/libs/common/src/misc/utils.ts#L141-L143 [2] https://github.com/bitwarden/mobile/blob/v2023.3.1/src/Core/Utilities/CoreHelpers.cs#L227-L234 --- src/api/core/accounts.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs index 7cc18474..332fda77 100644 --- a/src/api/core/accounts.rs +++ b/src/api/core/accounts.rs @@ -899,7 +899,7 @@ impl<'r> FromRequest<'r> for KnownDevice { async fn from_request(req: &'r Request<'_>) -> Outcome { let email = if let Some(email_b64) = req.headers().get_one("X-Request-Email") { - let email_bytes = match data_encoding::BASE64URL.decode(email_b64.as_bytes()) { + let email_bytes = match data_encoding::BASE64URL_NOPAD.decode(email_b64.as_bytes()) { Ok(bytes) => bytes, Err(_) => { return Outcome::Failure((