mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-06-10 20:49:13 +03:00
Compare commits
7 Commits
1.35.8
...
62748100f0
| Author | SHA1 | Date | |
|---|---|---|---|
| 62748100f0 | |||
| fcbdebd6d7 | |||
| 454b8e2a35 | |||
| 7883da554e | |||
| fd2b6528a9 | |||
| cc57e60886 | |||
| e5681258f0 |
@@ -301,6 +301,7 @@ branches_sharing_code = "deny"
|
|||||||
case_sensitive_file_extension_comparisons = "deny"
|
case_sensitive_file_extension_comparisons = "deny"
|
||||||
cast_lossless = "deny"
|
cast_lossless = "deny"
|
||||||
clone_on_ref_ptr = "deny"
|
clone_on_ref_ptr = "deny"
|
||||||
|
duration_suboptimal_units = "deny"
|
||||||
equatable_if_let = "deny"
|
equatable_if_let = "deny"
|
||||||
excessive_precision = "deny"
|
excessive_precision = "deny"
|
||||||
filter_map_next = "deny"
|
filter_map_next = "deny"
|
||||||
@@ -322,6 +323,7 @@ needless_continue = "deny"
|
|||||||
needless_lifetimes = "deny"
|
needless_lifetimes = "deny"
|
||||||
option_option = "deny"
|
option_option = "deny"
|
||||||
redundant_clone = "deny"
|
redundant_clone = "deny"
|
||||||
|
ref_option = "deny"
|
||||||
string_add_assign = "deny"
|
string_add_assign = "deny"
|
||||||
unnecessary_join = "deny"
|
unnecessary_join = "deny"
|
||||||
unnecessary_self_imports = "deny"
|
unnecessary_self_imports = "deny"
|
||||||
|
|||||||
+1
-1
@@ -469,7 +469,7 @@ async fn deauth_user(user_id: UserId, _token: AdminToken, conn: DbConn, nt: Noti
|
|||||||
|
|
||||||
if CONFIG.push_enabled() {
|
if CONFIG.push_enabled() {
|
||||||
for device in Device::find_push_devices_by_user(&user.uuid, &conn).await {
|
for device in Device::find_push_devices_by_user(&user.uuid, &conn).await {
|
||||||
match unregister_push_device(&device.push_uuid).await {
|
match unregister_push_device(device.push_uuid.as_ref()).await {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
Err(e) => error!("Unable to unregister devices from Bitwarden server: {e}"),
|
Err(e) => error!("Unable to unregister devices from Bitwarden server: {e}"),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ struct KeysData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Trims whitespace from password hints, and converts blank password hints to `None`.
|
/// Trims whitespace from password hints, and converts blank password hints to `None`.
|
||||||
fn clean_password_hint(password_hint: &Option<String>) -> Option<String> {
|
fn clean_password_hint(password_hint: Option<&String>) -> Option<String> {
|
||||||
match password_hint {
|
match password_hint {
|
||||||
None => None,
|
None => None,
|
||||||
Some(h) => match h.trim() {
|
Some(h) => match h.trim() {
|
||||||
@@ -147,7 +147,7 @@ fn clean_password_hint(password_hint: &Option<String>) -> Option<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enforce_password_hint_setting(password_hint: &Option<String>) -> EmptyResult {
|
fn enforce_password_hint_setting(password_hint: Option<&String>) -> EmptyResult {
|
||||||
if password_hint.is_some() && !CONFIG.password_hints_allowed() {
|
if password_hint.is_some() && !CONFIG.password_hints_allowed() {
|
||||||
err!("Password hints have been disabled by the administrator. Remove the hint and try again.");
|
err!("Password hints have been disabled by the administrator. Remove the hint and try again.");
|
||||||
}
|
}
|
||||||
@@ -245,8 +245,8 @@ pub async fn _register(data: Json<RegisterData>, email_verification: bool, conn:
|
|||||||
|
|
||||||
// Check against the password hint setting here so if it fails, the user
|
// Check against the password hint setting here so if it fails, the user
|
||||||
// can retry without losing their invitation below.
|
// can retry without losing their invitation below.
|
||||||
let password_hint = clean_password_hint(&data.master_password_hint);
|
let password_hint = clean_password_hint(data.master_password_hint.as_ref());
|
||||||
enforce_password_hint_setting(&password_hint)?;
|
enforce_password_hint_setting(password_hint.as_ref())?;
|
||||||
|
|
||||||
let mut user = match User::find_by_mail(&email, &conn).await {
|
let mut user = match User::find_by_mail(&email, &conn).await {
|
||||||
Some(user) => {
|
Some(user) => {
|
||||||
@@ -353,8 +353,8 @@ async fn post_set_password(data: Json<SetPasswordData>, headers: Headers, conn:
|
|||||||
|
|
||||||
// Check against the password hint setting here so if it fails,
|
// Check against the password hint setting here so if it fails,
|
||||||
// the user can retry without losing their invitation below.
|
// the user can retry without losing their invitation below.
|
||||||
let password_hint = clean_password_hint(&data.master_password_hint);
|
let password_hint = clean_password_hint(data.master_password_hint.as_ref());
|
||||||
enforce_password_hint_setting(&password_hint)?;
|
enforce_password_hint_setting(password_hint.as_ref())?;
|
||||||
|
|
||||||
set_kdf_data(&mut user, &data.kdf)?;
|
set_kdf_data(&mut user, &data.kdf)?;
|
||||||
|
|
||||||
@@ -515,8 +515,8 @@ async fn post_password(data: Json<ChangePassData>, headers: Headers, conn: DbCon
|
|||||||
err!("Invalid password")
|
err!("Invalid password")
|
||||||
}
|
}
|
||||||
|
|
||||||
user.password_hint = clean_password_hint(&data.master_password_hint);
|
user.password_hint = clean_password_hint(data.master_password_hint.as_ref());
|
||||||
enforce_password_hint_setting(&user.password_hint)?;
|
enforce_password_hint_setting(user.password_hint.as_ref())?;
|
||||||
|
|
||||||
log_user_event(EventType::UserChangedPassword as i32, &user.uuid, headers.device.atype, &headers.ip.ip, &conn)
|
log_user_event(EventType::UserChangedPassword as i32, &user.uuid, headers.device.atype, &headers.ip.ip, &conn)
|
||||||
.await;
|
.await;
|
||||||
@@ -1438,7 +1438,7 @@ async fn put_clear_device_token(device_id: DeviceId, conn: DbConn) -> EmptyResul
|
|||||||
|
|
||||||
if let Some(device) = Device::find_by_uuid(&device_id, &conn).await {
|
if let Some(device) = Device::find_by_uuid(&device_id, &conn).await {
|
||||||
Device::clear_push_token_by_uuid(&device_id, &conn).await?;
|
Device::clear_push_token_by_uuid(&device_id, &conn).await?;
|
||||||
unregister_push_device(&device.push_uuid).await?;
|
unregister_push_device(device.push_uuid.as_ref()).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -630,7 +630,7 @@ async fn post_ciphers_import(data: Json<ImportData>, headers: Headers, conn: DbC
|
|||||||
|
|
||||||
let mut user = headers.user;
|
let mut user = headers.user;
|
||||||
user.update_revision(&conn).await?;
|
user.update_revision(&conn).await?;
|
||||||
nt.send_user_update(UpdateType::SyncVault, &user, &headers.device.push_uuid, &conn).await;
|
nt.send_user_update(UpdateType::SyncVault, &user, headers.device.push_uuid.as_ref(), &conn).await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1005,7 +1005,7 @@ async fn put_cipher_share_selected(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Multi share actions do not send out a push for each cipher, we need to send a general sync here
|
// Multi share actions do not send out a push for each cipher, we need to send a general sync here
|
||||||
nt.send_user_update(UpdateType::SyncCiphers, &headers.user, &headers.device.push_uuid, &conn).await;
|
nt.send_user_update(UpdateType::SyncCiphers, &headers.user, headers.device.push_uuid.as_ref(), &conn).await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1618,7 +1618,7 @@ async fn move_cipher_selected(
|
|||||||
.await;
|
.await;
|
||||||
} else {
|
} else {
|
||||||
// Multi move actions do not send out a push for each cipher, we need to send a general sync here
|
// Multi move actions do not send out a push for each cipher, we need to send a general sync here
|
||||||
nt.send_user_update(UpdateType::SyncCiphers, &headers.user, &headers.device.push_uuid, &conn).await;
|
nt.send_user_update(UpdateType::SyncCiphers, &headers.user, headers.device.push_uuid.as_ref(), &conn).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
if cipher_count != accessible_ciphers_count {
|
if cipher_count != accessible_ciphers_count {
|
||||||
@@ -1670,7 +1670,7 @@ async fn purge_org_vault(
|
|||||||
match Membership::find_confirmed_by_user_and_org(&user.uuid, &organization.org_id, &conn).await {
|
match Membership::find_confirmed_by_user_and_org(&user.uuid, &organization.org_id, &conn).await {
|
||||||
Some(member) if member.atype == MembershipType::Owner => {
|
Some(member) if member.atype == MembershipType::Owner => {
|
||||||
Cipher::delete_all_by_organization(&organization.org_id, &conn).await?;
|
Cipher::delete_all_by_organization(&organization.org_id, &conn).await?;
|
||||||
nt.send_user_update(UpdateType::SyncVault, &user, &headers.device.push_uuid, &conn).await;
|
nt.send_user_update(UpdateType::SyncVault, &user, headers.device.push_uuid.as_ref(), &conn).await;
|
||||||
|
|
||||||
log_event(
|
log_event(
|
||||||
EventType::OrganizationPurgedVault as i32,
|
EventType::OrganizationPurgedVault as i32,
|
||||||
@@ -1710,7 +1710,7 @@ async fn purge_personal_vault(
|
|||||||
}
|
}
|
||||||
|
|
||||||
user.update_revision(&conn).await?;
|
user.update_revision(&conn).await?;
|
||||||
nt.send_user_update(UpdateType::SyncVault, &user, &headers.device.push_uuid, &conn).await;
|
nt.send_user_update(UpdateType::SyncVault, &user, headers.device.push_uuid.as_ref(), &conn).await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1805,7 +1805,7 @@ async fn _delete_multiple_ciphers(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Multi delete actions do not send out a push for each cipher, we need to send a general sync here
|
// Multi delete actions do not send out a push for each cipher, we need to send a general sync here
|
||||||
nt.send_user_update(UpdateType::SyncCiphers, &headers.user, &headers.device.push_uuid, &conn).await;
|
nt.send_user_update(UpdateType::SyncCiphers, &headers.user, headers.device.push_uuid.as_ref(), &conn).await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1873,7 +1873,7 @@ async fn _restore_multiple_ciphers(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Multi move actions do not send out a push for each cipher, we need to send a general sync here
|
// Multi move actions do not send out a push for each cipher, we need to send a general sync here
|
||||||
nt.send_user_update(UpdateType::SyncCiphers, &headers.user, &headers.device.push_uuid, conn).await;
|
nt.send_user_update(UpdateType::SyncCiphers, &headers.user, headers.device.push_uuid.as_ref(), conn).await;
|
||||||
|
|
||||||
Ok(Json(json!({
|
Ok(Json(json!({
|
||||||
"data": ciphers,
|
"data": ciphers,
|
||||||
|
|||||||
+1
-1
@@ -124,7 +124,7 @@ async fn post_eq_domains(data: Json<EquivDomainData>, headers: Headers, conn: Db
|
|||||||
|
|
||||||
user.save(&conn).await?;
|
user.save(&conn).await?;
|
||||||
|
|
||||||
nt.send_user_update(UpdateType::SyncSettings, &user, &headers.device.push_uuid, &conn).await;
|
nt.send_user_update(UpdateType::SyncSettings, &user, headers.device.push_uuid.as_ref(), &conn).await;
|
||||||
|
|
||||||
Ok(Json(json!({})))
|
Ok(Json(json!({})))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1463,7 +1463,7 @@ async fn _confirm_invite(
|
|||||||
let save_result = member_to_confirm.save(conn).await;
|
let save_result = member_to_confirm.save(conn).await;
|
||||||
|
|
||||||
if let Some(user) = User::find_by_uuid(&member_to_confirm.user_uuid, conn).await {
|
if let Some(user) = User::find_by_uuid(&member_to_confirm.user_uuid, conn).await {
|
||||||
nt.send_user_update(UpdateType::SyncOrgKeys, &user, &headers.device.push_uuid, conn).await;
|
nt.send_user_update(UpdateType::SyncOrgKeys, &user, headers.device.push_uuid.as_ref(), conn).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
save_result
|
save_result
|
||||||
@@ -1721,7 +1721,7 @@ async fn _delete_member(
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
if let Some(user) = User::find_by_uuid(&member_to_delete.user_uuid, conn).await {
|
if let Some(user) = User::find_by_uuid(&member_to_delete.user_uuid, conn).await {
|
||||||
nt.send_user_update(UpdateType::SyncOrgKeys, &user, &headers.device.push_uuid, conn).await;
|
nt.send_user_update(UpdateType::SyncOrgKeys, &user, headers.device.push_uuid.as_ref(), conn).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
member_to_delete.delete(conn).await
|
member_to_delete.delete(conn).await
|
||||||
@@ -1979,7 +1979,7 @@ async fn list_policies_token(org_id: OrganizationId, token: &str, conn: DbConn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Called during the SSO enrollment return the default policy
|
// Called during the SSO enrollment return the default policy
|
||||||
#[get("/organizations/vaultwarden-dummy-oidc-identifier/policies/master-password", rank = 1)]
|
#[get("/organizations/00000000-01DC-01DC-01DC-000000000000/policies/master-password", rank = 1)]
|
||||||
fn get_dummy_master_password_policy() -> JsonResult {
|
fn get_dummy_master_password_policy() -> JsonResult {
|
||||||
let (enabled, data) = match CONFIG.sso_master_password_policy_value() {
|
let (enabled, data) = match CONFIG.sso_master_password_policy_value() {
|
||||||
Some(policy) if CONFIG.sso_enabled() => (true, policy.to_string()),
|
Some(policy) if CONFIG.sso_enabled() => (true, policy.to_string()),
|
||||||
|
|||||||
@@ -574,7 +574,7 @@ async fn download_url(host: &Host, send_id: &SendId, file_id: &SendFileId) -> Re
|
|||||||
|
|
||||||
Ok(format!("{}/api/sends/{send_id}/{file_id}?t={token}", &host.host))
|
Ok(format!("{}/api/sends/{send_id}/{file_id}?t={token}", &host.host))
|
||||||
} else {
|
} else {
|
||||||
Ok(operator.presign_read(&format!("{send_id}/{file_id}"), Duration::from_secs(5 * 60)).await?.uri().to_string())
|
Ok(operator.presign_read(&format!("{send_id}/{file_id}"), Duration::from_mins(5)).await?.uri().to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ static WEBAUTHN: LazyLock<Webauthn> = LazyLock::new(|| {
|
|||||||
let webauthn = WebauthnBuilder::new(&rp_id, &rp_origin)
|
let webauthn = WebauthnBuilder::new(&rp_id, &rp_origin)
|
||||||
.expect("Creating WebauthnBuilder failed")
|
.expect("Creating WebauthnBuilder failed")
|
||||||
.rp_name(&domain)
|
.rp_name(&domain)
|
||||||
.timeout(Duration::from_millis(60000));
|
.timeout(Duration::from_mins(1));
|
||||||
|
|
||||||
webauthn.build().expect("Building Webauthn failed")
|
webauthn.build().expect("Building Webauthn failed")
|
||||||
});
|
});
|
||||||
|
|||||||
+33
-27
@@ -41,6 +41,7 @@ pub fn routes() -> Vec<Route> {
|
|||||||
routes![
|
routes![
|
||||||
login,
|
login,
|
||||||
prelogin,
|
prelogin,
|
||||||
|
prelogin_password,
|
||||||
identity_register,
|
identity_register,
|
||||||
register_verification_email,
|
register_verification_email,
|
||||||
register_finish,
|
register_finish,
|
||||||
@@ -64,43 +65,43 @@ async fn login(
|
|||||||
|
|
||||||
let login_result = match data.grant_type.as_ref() {
|
let login_result = match data.grant_type.as_ref() {
|
||||||
"refresh_token" => {
|
"refresh_token" => {
|
||||||
_check_is_some(&data.refresh_token, "refresh_token cannot be blank")?;
|
_check_is_some(data.refresh_token.as_ref(), "refresh_token cannot be blank")?;
|
||||||
_refresh_login(data, &conn, &client_header.ip).await
|
_refresh_login(data, &conn, &client_header.ip).await
|
||||||
}
|
}
|
||||||
"password" if CONFIG.sso_enabled() && CONFIG.sso_only() => err!("SSO sign-in is required"),
|
"password" if CONFIG.sso_enabled() && CONFIG.sso_only() => err!("SSO sign-in is required"),
|
||||||
"password" => {
|
"password" => {
|
||||||
_check_is_some(&data.client_id, "client_id cannot be blank")?;
|
_check_is_some(data.client_id.as_ref(), "client_id cannot be blank")?;
|
||||||
_check_is_some(&data.password, "password cannot be blank")?;
|
_check_is_some(data.password.as_ref(), "password cannot be blank")?;
|
||||||
_check_is_some(&data.scope, "scope cannot be blank")?;
|
_check_is_some(data.scope.as_ref(), "scope cannot be blank")?;
|
||||||
_check_is_some(&data.username, "username cannot be blank")?;
|
_check_is_some(data.username.as_ref(), "username cannot be blank")?;
|
||||||
|
|
||||||
_check_is_some(&data.device_identifier, "device_identifier cannot be blank")?;
|
_check_is_some(data.device_identifier.as_ref(), "device_identifier cannot be blank")?;
|
||||||
_check_is_some(&data.device_name, "device_name cannot be blank")?;
|
_check_is_some(data.device_name.as_ref(), "device_name cannot be blank")?;
|
||||||
_check_is_some(&data.device_type, "device_type cannot be blank")?;
|
_check_is_some(data.device_type.as_ref(), "device_type cannot be blank")?;
|
||||||
|
|
||||||
_password_login(data, &mut user_id, &conn, &client_header.ip, &client_version).await
|
_password_login(data, &mut user_id, &conn, &client_header.ip, client_version.as_ref()).await
|
||||||
}
|
}
|
||||||
"client_credentials" => {
|
"client_credentials" => {
|
||||||
_check_is_some(&data.client_id, "client_id cannot be blank")?;
|
_check_is_some(data.client_id.as_ref(), "client_id cannot be blank")?;
|
||||||
_check_is_some(&data.client_secret, "client_secret cannot be blank")?;
|
_check_is_some(data.client_secret.as_ref(), "client_secret cannot be blank")?;
|
||||||
_check_is_some(&data.scope, "scope cannot be blank")?;
|
_check_is_some(data.scope.as_ref(), "scope cannot be blank")?;
|
||||||
|
|
||||||
_check_is_some(&data.device_identifier, "device_identifier cannot be blank")?;
|
_check_is_some(data.device_identifier.as_ref(), "device_identifier cannot be blank")?;
|
||||||
_check_is_some(&data.device_name, "device_name cannot be blank")?;
|
_check_is_some(data.device_name.as_ref(), "device_name cannot be blank")?;
|
||||||
_check_is_some(&data.device_type, "device_type cannot be blank")?;
|
_check_is_some(data.device_type.as_ref(), "device_type cannot be blank")?;
|
||||||
|
|
||||||
_api_key_login(data, &mut user_id, &conn, &client_header.ip).await
|
_api_key_login(data, &mut user_id, &conn, &client_header.ip).await
|
||||||
}
|
}
|
||||||
"authorization_code" if CONFIG.sso_enabled() => {
|
"authorization_code" if CONFIG.sso_enabled() => {
|
||||||
_check_is_some(&data.client_id, "client_id cannot be blank")?;
|
_check_is_some(data.client_id.as_ref(), "client_id cannot be blank")?;
|
||||||
_check_is_some(&data.code, "code cannot be blank")?;
|
_check_is_some(data.code.as_ref(), "code cannot be blank")?;
|
||||||
_check_is_some(&data.code_verifier, "code verifier cannot be blank")?;
|
_check_is_some(data.code_verifier.as_ref(), "code verifier cannot be blank")?;
|
||||||
|
|
||||||
_check_is_some(&data.device_identifier, "device_identifier cannot be blank")?;
|
_check_is_some(data.device_identifier.as_ref(), "device_identifier cannot be blank")?;
|
||||||
_check_is_some(&data.device_name, "device_name cannot be blank")?;
|
_check_is_some(data.device_name.as_ref(), "device_name cannot be blank")?;
|
||||||
_check_is_some(&data.device_type, "device_type cannot be blank")?;
|
_check_is_some(data.device_type.as_ref(), "device_type cannot be blank")?;
|
||||||
|
|
||||||
_sso_login(data, &mut user_id, &conn, &client_header.ip, &client_version).await
|
_sso_login(data, &mut user_id, &conn, &client_header.ip, client_version.as_ref()).await
|
||||||
}
|
}
|
||||||
"authorization_code" => err!("SSO sign-in is not available"),
|
"authorization_code" => err!("SSO sign-in is not available"),
|
||||||
t => err!("Invalid type", t),
|
t => err!("Invalid type", t),
|
||||||
@@ -176,7 +177,7 @@ async fn _sso_login(
|
|||||||
user_id: &mut Option<UserId>,
|
user_id: &mut Option<UserId>,
|
||||||
conn: &DbConn,
|
conn: &DbConn,
|
||||||
ip: &ClientIp,
|
ip: &ClientIp,
|
||||||
client_version: &Option<ClientVersion>,
|
client_version: Option<&ClientVersion>,
|
||||||
) -> JsonResult {
|
) -> JsonResult {
|
||||||
AuthMethod::Sso.check_scope(data.scope.as_ref())?;
|
AuthMethod::Sso.check_scope(data.scope.as_ref())?;
|
||||||
|
|
||||||
@@ -319,7 +320,7 @@ async fn _password_login(
|
|||||||
user_id: &mut Option<UserId>,
|
user_id: &mut Option<UserId>,
|
||||||
conn: &DbConn,
|
conn: &DbConn,
|
||||||
ip: &ClientIp,
|
ip: &ClientIp,
|
||||||
client_version: &Option<ClientVersion>,
|
client_version: Option<&ClientVersion>,
|
||||||
) -> JsonResult {
|
) -> JsonResult {
|
||||||
// Validate scope
|
// Validate scope
|
||||||
AuthMethod::Password.check_scope(data.scope.as_ref())?;
|
AuthMethod::Password.check_scope(data.scope.as_ref())?;
|
||||||
@@ -733,7 +734,7 @@ async fn twofactor_auth(
|
|||||||
data: &ConnectData,
|
data: &ConnectData,
|
||||||
device: &mut Device,
|
device: &mut Device,
|
||||||
ip: &ClientIp,
|
ip: &ClientIp,
|
||||||
client_version: &Option<ClientVersion>,
|
client_version: Option<&ClientVersion>,
|
||||||
conn: &DbConn,
|
conn: &DbConn,
|
||||||
) -> ApiResult<Option<String>> {
|
) -> ApiResult<Option<String>> {
|
||||||
let twofactors = TwoFactor::find_by_user(&user.uuid, conn).await;
|
let twofactors = TwoFactor::find_by_user(&user.uuid, conn).await;
|
||||||
@@ -878,7 +879,7 @@ async fn _json_err_twofactor(
|
|||||||
providers: &[i32],
|
providers: &[i32],
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
data: &ConnectData,
|
data: &ConnectData,
|
||||||
client_version: &Option<ClientVersion>,
|
client_version: Option<&ClientVersion>,
|
||||||
conn: &DbConn,
|
conn: &DbConn,
|
||||||
) -> ApiResult<Value> {
|
) -> ApiResult<Value> {
|
||||||
let mut result = json!({
|
let mut result = json!({
|
||||||
@@ -982,6 +983,11 @@ async fn prelogin(data: Json<PreloginData>, conn: DbConn) -> Json<Value> {
|
|||||||
_prelogin(data, conn).await
|
_prelogin(data, conn).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[post("/accounts/prelogin/password", data = "<data>")]
|
||||||
|
async fn prelogin_password(data: Json<PreloginData>, conn: DbConn) -> Json<Value> {
|
||||||
|
_prelogin(data, conn).await
|
||||||
|
}
|
||||||
|
|
||||||
#[post("/accounts/register", data = "<data>")]
|
#[post("/accounts/register", data = "<data>")]
|
||||||
async fn identity_register(data: Json<RegisterData>, conn: DbConn) -> JsonResult {
|
async fn identity_register(data: Json<RegisterData>, conn: DbConn) -> JsonResult {
|
||||||
_register(data, false, conn).await
|
_register(data, false, conn).await
|
||||||
@@ -1108,7 +1114,7 @@ struct ConnectData {
|
|||||||
#[field(name = uncased("code_verifier"))]
|
#[field(name = uncased("code_verifier"))]
|
||||||
code_verifier: Option<OIDCCodeVerifier>,
|
code_verifier: Option<OIDCCodeVerifier>,
|
||||||
}
|
}
|
||||||
fn _check_is_some<T>(value: &Option<T>, msg: &str) -> EmptyResult {
|
fn _check_is_some<T>(value: Option<&T>, msg: &str) -> EmptyResult {
|
||||||
if value.is_none() {
|
if value.is_none() {
|
||||||
err!(msg)
|
err!(msg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ impl WebSocketUsers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: The last modified date needs to be updated before calling these methods
|
// NOTE: The last modified date needs to be updated before calling these methods
|
||||||
pub async fn send_user_update(&self, ut: UpdateType, user: &User, push_uuid: &Option<PushId>, conn: &DbConn) {
|
pub async fn send_user_update(&self, ut: UpdateType, user: &User, push_uuid: Option<&PushId>, conn: &DbConn) {
|
||||||
// Skip any processing if both WebSockets and Push are not active
|
// Skip any processing if both WebSockets and Push are not active
|
||||||
if *NOTIFICATIONS_DISABLED {
|
if *NOTIFICATIONS_DISABLED {
|
||||||
return;
|
return;
|
||||||
|
|||||||
+2
-2
@@ -135,7 +135,7 @@ pub async fn register_push_device(device: &mut Device, conn: &DbConn) -> EmptyRe
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn unregister_push_device(push_id: &Option<PushId>) -> EmptyResult {
|
pub async fn unregister_push_device(push_id: Option<&PushId>) -> EmptyResult {
|
||||||
if !CONFIG.push_enabled() || push_id.is_none() {
|
if !CONFIG.push_enabled() || push_id.is_none() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -206,7 +206,7 @@ pub async fn push_logout(user: &User, acting_device: Option<&Device>, conn: &DbC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn push_user_update(ut: UpdateType, user: &User, push_uuid: &Option<PushId>, conn: &DbConn) {
|
pub async fn push_user_update(ut: UpdateType, user: &User, push_uuid: Option<&PushId>, conn: &DbConn) {
|
||||||
if Device::check_user_has_push_device(&user.uuid, conn).await {
|
if Device::check_user_has_push_device(&user.uuid, conn).await {
|
||||||
tokio::task::spawn(send_to_push_relay(json!({
|
tokio::task::spawn(send_to_push_relay(json!({
|
||||||
"userId": user.uuid,
|
"userId": user.uuid,
|
||||||
|
|||||||
+3
-3
@@ -1076,7 +1076,7 @@ fn validate_config(cfg: &ConfigItems, on_update: bool) -> Result<(), Error> {
|
|||||||
|
|
||||||
validate_internal_sso_issuer_url(&cfg.sso_authority)?;
|
validate_internal_sso_issuer_url(&cfg.sso_authority)?;
|
||||||
validate_internal_sso_redirect_url(&cfg.sso_callback_path)?;
|
validate_internal_sso_redirect_url(&cfg.sso_callback_path)?;
|
||||||
validate_sso_master_password_policy(&cfg.sso_master_password_policy)?;
|
validate_sso_master_password_policy(cfg.sso_master_password_policy.as_ref())?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg._enable_yubico {
|
if cfg._enable_yubico {
|
||||||
@@ -1271,7 +1271,7 @@ fn validate_internal_sso_redirect_url(sso_callback_path: &String) -> Result<open
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn validate_sso_master_password_policy(
|
fn validate_sso_master_password_policy(
|
||||||
sso_master_password_policy: &Option<String>,
|
sso_master_password_policy: Option<&String>,
|
||||||
) -> Result<Option<serde_json::Value>, Error> {
|
) -> Result<Option<serde_json::Value>, Error> {
|
||||||
let policy = sso_master_password_policy.as_ref().map(|mpp| serde_json::from_str::<serde_json::Value>(mpp));
|
let policy = sso_master_password_policy.as_ref().map(|mpp| serde_json::from_str::<serde_json::Value>(mpp));
|
||||||
|
|
||||||
@@ -1725,7 +1725,7 @@ impl Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn sso_master_password_policy_value(&self) -> Option<serde_json::Value> {
|
pub fn sso_master_password_policy_value(&self) -> Option<serde_json::Value> {
|
||||||
validate_sso_master_password_policy(&self.sso_master_password_policy()).ok().flatten()
|
validate_sso_master_password_policy(self.sso_master_password_policy().as_ref()).ok().flatten()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sso_scopes_vec(&self) -> Vec<String> {
|
pub fn sso_scopes_vec(&self) -> Vec<String> {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ impl Attachment {
|
|||||||
let token = encode_jwt(&generate_file_download_claims(self.cipher_uuid.clone(), self.id.clone()));
|
let token = encode_jwt(&generate_file_download_claims(self.cipher_uuid.clone(), self.id.clone()));
|
||||||
Ok(format!("{host}/attachments/{}/{}?token={token}", self.cipher_uuid, self.id))
|
Ok(format!("{host}/attachments/{}/{}?token={token}", self.cipher_uuid, self.id))
|
||||||
} else {
|
} else {
|
||||||
Ok(operator.presign_read(&self.get_file_path(), Duration::from_secs(5 * 60)).await?.uri().to_string())
|
Ok(operator.presign_read(&self.get_file_path(), Duration::from_mins(5)).await?.uri().to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ pub struct Device {
|
|||||||
pub user_uuid: UserId,
|
pub user_uuid: UserId,
|
||||||
|
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub atype: i32, // https://github.com/bitwarden/server/blob/9ebe16587175b1c0e9208f84397bb75d0d595510/src/Core/Enums/DeviceType.cs
|
pub atype: i32, // https://github.com/bitwarden/server/blob/8d547dcc280babab70dd4a3c94ced6a34b12dfbf/src/Core/Enums/DeviceType.cs
|
||||||
pub push_uuid: Option<PushId>,
|
pub push_uuid: Option<PushId>,
|
||||||
pub push_token: Option<String>,
|
pub push_token: Option<String>,
|
||||||
|
|
||||||
@@ -332,6 +332,8 @@ pub enum DeviceType {
|
|||||||
MacOsCLI = 24,
|
MacOsCLI = 24,
|
||||||
#[display("Linux CLI")]
|
#[display("Linux CLI")]
|
||||||
LinuxCLI = 25,
|
LinuxCLI = 25,
|
||||||
|
#[display("DuckDuckGo")]
|
||||||
|
DuckDuckGoBrowser = 26,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeviceType {
|
impl DeviceType {
|
||||||
@@ -363,6 +365,7 @@ impl DeviceType {
|
|||||||
23 => DeviceType::WindowsCLI,
|
23 => DeviceType::WindowsCLI,
|
||||||
24 => DeviceType::MacOsCLI,
|
24 => DeviceType::MacOsCLI,
|
||||||
25 => DeviceType::LinuxCLI,
|
25 => DeviceType::LinuxCLI,
|
||||||
|
26 => DeviceType::DuckDuckGoBrowser,
|
||||||
_ => DeviceType::UnknownBrowser,
|
_ => DeviceType::UnknownBrowser,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -17,7 +17,7 @@ use crate::{
|
|||||||
CONFIG,
|
CONFIG,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub static FAKE_SSO_IDENTIFIER: &str = "vaultwarden-dummy-oidc-identifier";
|
pub static FAKE_SSO_IDENTIFIER: &str = "00000000-01DC-01DC-01DC-000000000000";
|
||||||
|
|
||||||
static SSO_JWT_ISSUER: LazyLock<String> = LazyLock::new(|| format!("{}|sso", CONFIG.domain_origin()));
|
static SSO_JWT_ISSUER: LazyLock<String> = LazyLock::new(|| format!("{}|sso", CONFIG.domain_origin()));
|
||||||
|
|
||||||
@@ -283,7 +283,7 @@ pub async fn exchange_code(
|
|||||||
|
|
||||||
let email_verified = id_claims.email_verified().or(user_info.email_verified());
|
let email_verified = id_claims.email_verified().or(user_info.email_verified());
|
||||||
|
|
||||||
let user_name = id_claims.preferred_username().map(|un| un.to_string());
|
let user_name = id_claims.preferred_username().or(user_info.preferred_username()).map(|un| un.to_string());
|
||||||
|
|
||||||
let refresh_token = token_response.refresh_token().map(|t| t.secret());
|
let refresh_token = token_response.refresh_token().map(|t| t.secret());
|
||||||
if refresh_token.is_none() && CONFIG.sso_scopes_vec().contains(&"offline_access".to_string()) {
|
if refresh_token.is_none() && CONFIG.sso_scopes_vec().contains(&"offline_access".to_string()) {
|
||||||
|
|||||||
+1
-1
@@ -734,7 +734,7 @@ where
|
|||||||
|
|
||||||
warn!("Can't connect to database, retrying: {e:?}");
|
warn!("Can't connect to database, retrying: {e:?}");
|
||||||
|
|
||||||
sleep(Duration::from_millis(1_000)).await;
|
sleep(Duration::from_secs(1)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user