Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-16 04:12:53 +01:00
cargo clippy and cargo fmt
Dieser Commit ist enthalten in:
Ursprung
96261f1284
Commit
edcd2640d0
3 geänderte Dateien mit 15 neuen und 28 gelöschten Zeilen
|
@ -113,14 +113,8 @@ async fn sync(data: SyncData, headers: Headers, mut conn: DbConn) -> Json<Value>
|
||||||
let mut ciphers_json = Vec::with_capacity(ciphers.len());
|
let mut ciphers_json = Vec::with_capacity(ciphers.len());
|
||||||
for c in ciphers {
|
for c in ciphers {
|
||||||
ciphers_json.push(
|
ciphers_json.push(
|
||||||
c.to_json(
|
c.to_json(&headers.base_url, &headers.user.uuid, Some(&cipher_sync_data), CipherSyncType::User, &mut conn)
|
||||||
&headers.base_url,
|
.await,
|
||||||
&headers.user.uuid,
|
|
||||||
Some(&cipher_sync_data),
|
|
||||||
CipherSyncType::User,
|
|
||||||
&mut conn,
|
|
||||||
)
|
|
||||||
.await,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,14 +160,8 @@ async fn get_ciphers(headers: Headers, mut conn: DbConn) -> Json<Value> {
|
||||||
let mut ciphers_json = Vec::with_capacity(ciphers.len());
|
let mut ciphers_json = Vec::with_capacity(ciphers.len());
|
||||||
for c in ciphers {
|
for c in ciphers {
|
||||||
ciphers_json.push(
|
ciphers_json.push(
|
||||||
c.to_json(
|
c.to_json(&headers.base_url, &headers.user.uuid, Some(&cipher_sync_data), CipherSyncType::User, &mut conn)
|
||||||
&headers.base_url,
|
.await,
|
||||||
&headers.user.uuid,
|
|
||||||
Some(&cipher_sync_data),
|
|
||||||
CipherSyncType::User,
|
|
||||||
&mut conn,
|
|
||||||
)
|
|
||||||
.await,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -777,9 +777,8 @@ async fn _get_org_details(org_id: &str, base_url: &str, user_uuid: &str, conn: &
|
||||||
|
|
||||||
let mut ciphers_json = Vec::with_capacity(ciphers.len());
|
let mut ciphers_json = Vec::with_capacity(ciphers.len());
|
||||||
for c in ciphers {
|
for c in ciphers {
|
||||||
ciphers_json.push(
|
ciphers_json
|
||||||
c.to_json(base_url, user_uuid, Some(&cipher_sync_data), CipherSyncType::Organization, conn).await,
|
.push(c.to_json(base_url, user_uuid, Some(&cipher_sync_data), CipherSyncType::Organization, conn).await);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
json!(ciphers_json)
|
json!(ciphers_json)
|
||||||
}
|
}
|
||||||
|
|
18
src/auth.rs
18
src/auth.rs
|
@ -9,7 +9,7 @@ use openssl::rsa::Rsa;
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use serde::ser::Serialize;
|
use serde::ser::Serialize;
|
||||||
|
|
||||||
use crate::config::{extract_url_origin, extract_url_host};
|
use crate::config::{extract_url_host, extract_url_origin};
|
||||||
use crate::{error::Error, CONFIG};
|
use crate::{error::Error, CONFIG};
|
||||||
|
|
||||||
const JWT_ALGORITHM: Algorithm = Algorithm::RS256;
|
const JWT_ALGORITHM: Algorithm = Algorithm::RS256;
|
||||||
|
@ -372,10 +372,12 @@ pub struct HostInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_host_info(host: &str) -> Option<HostInfo> {
|
fn get_host_info(host: &str) -> Option<HostInfo> {
|
||||||
CONFIG
|
CONFIG.host_to_domain(host).and_then(|base_url| Some((base_url, CONFIG.domain_origin(host)?))).map(
|
||||||
.host_to_domain(host)
|
|(base_url, origin)| HostInfo {
|
||||||
.and_then(|base_url| Some((base_url, CONFIG.domain_origin(host)?)))
|
base_url,
|
||||||
.and_then(|(base_url, origin)| Some(HostInfo { base_url, origin }))
|
origin,
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_main_host() -> String {
|
fn get_main_host() -> String {
|
||||||
|
@ -399,11 +401,9 @@ impl<'r> FromRequest<'r> for HostInfo {
|
||||||
} else {
|
} else {
|
||||||
get_main_host().into()
|
get_main_host().into()
|
||||||
};
|
};
|
||||||
|
|
||||||
let host_info = get_host_info(host.as_ref())
|
let host_info = get_host_info(host.as_ref())
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| get_host_info(&get_main_host()).expect("Main domain doesn't have entry!"));
|
||||||
get_host_info(&get_main_host()).expect("Main domain doesn't have entry!")
|
|
||||||
});
|
|
||||||
|
|
||||||
return Outcome::Success(host_info);
|
return Outcome::Success(host_info);
|
||||||
} else if let Some(referer) = headers.get_one("Referer") {
|
} else if let Some(referer) = headers.get_one("Referer") {
|
||||||
|
|
Laden …
In neuem Issue referenzieren