|
|
@ -12,9 +12,11 @@ use serde_json::Value; |
|
|
|
|
|
|
|
|
use crate::{ |
|
|
use crate::{ |
|
|
CONFIG, |
|
|
CONFIG, |
|
|
api::{self, EmptyResult, JsonResult, Notify, PasswordOrOtpData, UpdateType, core::log_event}, |
|
|
api::{ |
|
|
auth::ClientVersion, |
|
|
self, EmptyResult, JsonResult, Notify, PasswordOrOtpData, UpdateType, |
|
|
auth::{Headers, OrgIdGuard, OwnerHeaders}, |
|
|
core::{log_event, webauthn_prf_option}, |
|
|
|
|
|
}, |
|
|
|
|
|
auth::{ClientVersion, Headers, OrgIdGuard, OwnerHeaders}, |
|
|
config::PathType, |
|
|
config::PathType, |
|
|
crypto, |
|
|
crypto, |
|
|
db::{ |
|
|
db::{ |
|
|
@ -22,7 +24,7 @@ use crate::{ |
|
|
models::{ |
|
|
models::{ |
|
|
Archive, Attachment, AttachmentId, Cipher, CipherId, Collection, CollectionCipher, CollectionGroup, |
|
|
Archive, Attachment, AttachmentId, Cipher, CipherId, Collection, CollectionCipher, CollectionGroup, |
|
|
CollectionId, CollectionUser, EventType, Favorite, Folder, FolderCipher, FolderId, Group, Membership, |
|
|
CollectionId, CollectionUser, EventType, Favorite, Folder, FolderCipher, FolderId, Group, Membership, |
|
|
MembershipType, OrgPolicy, OrgPolicyType, OrganizationId, RepromptType, Send, UserId, |
|
|
MembershipType, OrgPolicy, OrgPolicyType, OrganizationId, RepromptType, Send, UserId, WebauthnCredential, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
util::{NumberOrString, deser_opt_nonempty_str, save_temp_file}, |
|
|
util::{NumberOrString, deser_opt_nonempty_str, save_temp_file}, |
|
|
@ -188,6 +190,12 @@ async fn sync(data: SyncData, headers: Headers, client_version: Option<ClientVer |
|
|
Value::Null |
|
|
Value::Null |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let webauthn_prf_options = WebauthnCredential::find_all_by_user(&headers.user.uuid, &conn) |
|
|
|
|
|
.await |
|
|
|
|
|
.iter() |
|
|
|
|
|
.filter_map(|wac| webauthn_prf_option(wac, false)) |
|
|
|
|
|
.collect(); |
|
|
|
|
|
|
|
|
Ok(Json(json!({ |
|
|
Ok(Json(json!({ |
|
|
"profile": user_json, |
|
|
"profile": user_json, |
|
|
"folders": folders_json, |
|
|
"folders": folders_json, |
|
|
@ -196,13 +204,21 @@ 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": { |
|
|
"userDecryption": sync_user_decryption(&master_password_unlock, webauthn_prf_options), |
|
|
"masterPasswordUnlock": master_password_unlock, |
|
|
|
|
|
}, |
|
|
|
|
|
"object": "sync" |
|
|
"object": "sync" |
|
|
}))) |
|
|
}))) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn sync_user_decryption(master_password_unlock: &Value, webauthn_prf_options: Vec<Value>) -> Value { |
|
|
|
|
|
let mut user_decryption = json!({ |
|
|
|
|
|
"masterPasswordUnlock": master_password_unlock, |
|
|
|
|
|
}); |
|
|
|
|
|
if !webauthn_prf_options.is_empty() { |
|
|
|
|
|
user_decryption["webAuthnPrfOptions"] = webauthn_prf_options.into(); |
|
|
|
|
|
} |
|
|
|
|
|
user_decryption |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
#[get("/ciphers")] |
|
|
#[get("/ciphers")] |
|
|
async fn get_ciphers(headers: Headers, conn: DbConn) -> JsonResult { |
|
|
async fn get_ciphers(headers: Headers, conn: DbConn) -> JsonResult { |
|
|
let ciphers = Cipher::find_by_user_visible(&headers.user.uuid, &conn).await; |
|
|
let ciphers = Cipher::find_by_user_visible(&headers.user.uuid, &conn).await; |
|
|
|