mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-01-16 12:43:02 +00:00
Add UserDecryptionOptions on /sync too (#6574)
This commit is contained in:
@@ -159,7 +159,25 @@ async fn sync(data: SyncData, headers: Headers, client_version: Option<ClientVer
|
|||||||
let domains_json = if data.exclude_domains {
|
let domains_json = if data.exclude_domains {
|
||||||
Value::Null
|
Value::Null
|
||||||
} else {
|
} else {
|
||||||
api::core::_get_eq_domains(headers, true).into_inner()
|
api::core::_get_eq_domains(&headers, true).into_inner()
|
||||||
|
};
|
||||||
|
|
||||||
|
// This is very similar to the the userDecryptionOptions sent in connect/token,
|
||||||
|
// but as of 2025-12-19 they're both using different casing conventions.
|
||||||
|
let has_master_password = !headers.user.password_hash.is_empty();
|
||||||
|
let master_password_unlock = if has_master_password {
|
||||||
|
json!({
|
||||||
|
"kdf": {
|
||||||
|
"kdfType": headers.user.client_kdf_type,
|
||||||
|
"iterations": headers.user.client_kdf_iter,
|
||||||
|
"memory": headers.user.client_kdf_memory,
|
||||||
|
"parallelism": headers.user.client_kdf_parallelism
|
||||||
|
},
|
||||||
|
"masterKeyEncryptedUserKey": headers.user.akey,
|
||||||
|
"salt": headers.user.email
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Value::Null
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Json(json!({
|
Ok(Json(json!({
|
||||||
@@ -170,6 +188,9 @@ async fn sync(data: SyncData, headers: Headers, client_version: Option<ClientVer
|
|||||||
"ciphers": ciphers_json,
|
"ciphers": ciphers_json,
|
||||||
"domains": domains_json,
|
"domains": domains_json,
|
||||||
"sends": sends_json,
|
"sends": sends_json,
|
||||||
|
"userDecryption": {
|
||||||
|
"masterPasswordUnlock": master_password_unlock,
|
||||||
|
},
|
||||||
"object": "sync"
|
"object": "sync"
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,11 +74,11 @@ const GLOBAL_DOMAINS: &str = include_str!("../../static/global_domains.json");
|
|||||||
|
|
||||||
#[get("/settings/domains")]
|
#[get("/settings/domains")]
|
||||||
fn get_eq_domains(headers: Headers) -> Json<Value> {
|
fn get_eq_domains(headers: Headers) -> Json<Value> {
|
||||||
_get_eq_domains(headers, false)
|
_get_eq_domains(&headers, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _get_eq_domains(headers: Headers, no_excluded: bool) -> Json<Value> {
|
fn _get_eq_domains(headers: &Headers, no_excluded: bool) -> Json<Value> {
|
||||||
let user = headers.user;
|
let user = &headers.user;
|
||||||
use serde_json::from_str;
|
use serde_json::from_str;
|
||||||
|
|
||||||
let equivalent_domains: Vec<Vec<String>> = from_str(&user.equivalent_domains).unwrap();
|
let equivalent_domains: Vec<Vec<String>> = from_str(&user.equivalent_domains).unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user