From c150818e191a431acf7402b8ef0a2463428f4a03 Mon Sep 17 00:00:00 2001 From: BlockListed <44610569+BlockListed@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:15:20 +0100 Subject: [PATCH] rebase and fix rebase issues --- src/api/admin.rs | 5 ----- src/api/core/sends.rs | 4 +--- src/api/core/two_factor/webauthn.rs | 17 +++++++++-------- src/api/identity.rs | 4 +++- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/api/admin.rs b/src/api/admin.rs index d3007b18ac..66b3e01265 100644 --- a/src/api/admin.rs +++ b/src/api/admin.rs @@ -98,10 +98,6 @@ const BASE_TEMPLATE: &str = "admin/base"; const ACTING_ADMIN_USER: &str = "vaultwarden-admin-00000-000000000000"; -fn admin_path() -> String { - ADMIN_PATH.to_string() -} - #[derive(Debug)] struct IpHeader(Option); @@ -132,7 +128,6 @@ fn admin_url(origin: &str) -> String { format!("{}{}", origin, admin_path()) } - #[derive(Responder)] enum AdminResponse { #[response(status = 200)] diff --git a/src/api/core/sends.rs b/src/api/core/sends.rs index a34d8b9728..5e1439588d 100644 --- a/src/api/core/sends.rs +++ b/src/api/core/sends.rs @@ -9,9 +9,7 @@ use rocket::serde::json::Json; use serde_json::Value; use crate::{ - api::{ApiResult, EmptyResult, JsonResult, JsonUpcase, Notify, NumberOrString, UpdateType}, - auth::{ClientIp, Headers, HostInfo}, - api::{ApiResult, EmptyResult, JsonResult, JsonUpcase, Notify, NumberOrString, UpdateType}, + api::{ApiResult, EmptyResult, JsonResult, JsonUpcase, Notify, UpdateType}, auth::{ClientIp, Headers, HostInfo}, db::{models::*, DbConn, DbPool}, util::{NumberOrString, SafeString}, diff --git a/src/api/core/two_factor/webauthn.rs b/src/api/core/two_factor/webauthn.rs index 96e33ba210..b99d9a90c3 100644 --- a/src/api/core/two_factor/webauthn.rs +++ b/src/api/core/two_factor/webauthn.rs @@ -141,14 +141,15 @@ async fn generate_webauthn_challenge( .map(|r| r.credential.cred_id) // We return the credentialIds to the clients to avoid double registering .collect(); - let (challenge, state) = WebauthnConfig::load(&host_info.base_url, &host_info.origin).generate_challenge_register_options( - user.uuid.as_bytes().to_vec(), - user.email, - user.name, - Some(registrations), - None, - None, - )?; + let (challenge, state) = WebauthnConfig::load(&host_info.base_url, &host_info.origin) + .generate_challenge_register_options( + user.uuid.as_bytes().to_vec(), + user.email, + user.name, + Some(registrations), + None, + None, + )?; let type_ = TwoFactorType::WebauthnRegisterChallenge; TwoFactor::new(user.uuid, type_, serde_json::to_string(&state)?).save(&mut conn).await?; diff --git a/src/api/identity.rs b/src/api/identity.rs index 55e2556f00..7ce53a7bf1 100644 --- a/src/api/identity.rs +++ b/src/api/identity.rs @@ -524,7 +524,9 @@ async fn twofactor_auth( Some(TwoFactorType::Authenticator) => { authenticator::validate_totp_code_str(&user.uuid, twofactor_code, &selected_data?, ip, conn).await? } - Some(TwoFactorType::Webauthn) => webauthn::validate_webauthn_login(&user.uuid, twofactor_code, base_url, origin, conn).await?, + Some(TwoFactorType::Webauthn) => { + webauthn::validate_webauthn_login(&user.uuid, twofactor_code, base_url, origin, conn).await? + } Some(TwoFactorType::YubiKey) => yubikey::validate_yubikey_login(twofactor_code, &selected_data?).await?, Some(TwoFactorType::Duo) => { duo::validate_duo_login(data.username.as_ref().unwrap().trim(), twofactor_code, conn).await?