0
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden synced 2024-05-29 02:03:49 +02:00

Compare commits

..

4 commits

Author SHA1 Message Date
Stefan Melmuk 670099f1ca
Merge 0045330880 into 0fe93edea6 2024-04-28 13:32:53 +00:00
Stefan Melmuk 0045330880
update webauthn-rs to 0.5 2024-04-28 15:32:25 +02:00
Stefan Melmuk 035a843c71
fix u2f migration 2024-04-28 15:32:25 +02:00
Stefan Melmuk 257829c6ab
update webauthn-rs crate 2024-04-28 15:32:25 +02:00

View file

@ -44,6 +44,25 @@ pub struct U2FRegistration {
pub migrated: Option<bool>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct WebauthnRegistration {
pub id: i32,
pub name: String,
pub migrated: bool,
pub security_key: SecurityKey,
}
impl WebauthnRegistration {
fn to_json(&self) -> Value {
json!({
"Id": self.id,
"Name": self.name,
"migrated": self.migrated,
})
}
}
#[post("/two-factor/get-webauthn", data = "<data>")]
async fn get_webauthn(data: JsonUpcase<PasswordOrOtpData>, headers: Headers, mut conn: DbConn) -> JsonResult {
if !CONFIG.domain_set() {
@ -220,25 +239,6 @@ async fn delete_webauthn(data: JsonUpcase<DeleteU2FData>, headers: Headers, mut
})))
}
#[derive(Debug, Serialize, Deserialize)]
pub struct WebauthnRegistration {
pub id: i32,
pub name: String,
pub migrated: bool,
pub security_key: SecurityKey,
}
impl WebauthnRegistration {
fn to_json(&self) -> Value {
json!({
"Id": self.id,
"Name": self.name,
"migrated": self.migrated,
})
}
}
pub async fn get_webauthn_registrations(
user_uuid: &str,
conn: &mut DbConn,
@ -260,7 +260,6 @@ pub async fn generate_webauthn_login(user_uuid: &str, conn: &mut DbConn) -> Json
}
// Generate a challenge based on the credentials
//let ext = RequestAuthenticationExtensions::builder().appid(format!("{}/app-id.json", &CONFIG.domain())).build();
let (response, state) = WEBAUTHN.start_securitykey_authentication(&creds)?; //, Some(ext))?;
// Save the challenge state for later validation
@ -289,7 +288,6 @@ pub async fn validate_webauthn_login(user_uuid: &str, response: &str, conn: &mut
};
let rsp: PublicKeyCredential = serde_json::from_str(response)?;
// let rsp: PublicKeyCredential = rsp.data.into();
let mut registrations = get_webauthn_registrations(user_uuid, conn).await?.1;