Browse Source

Merge branch 'main' into fix/fallback

pull/7770/head
Mathijs van Veluw 1 month ago
committed by GitHub
parent
commit
d4a23f21aa
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      .env.template
  2. 26
      src/api/admin.rs
  3. 1
      src/api/web.rs
  4. 2
      src/config.rs
  5. 18
      src/http_client.rs
  6. 7
      src/static/templates/scss/vaultwarden.scss.hbs
  7. 14
      src/util.rs

1
.env.template

@ -409,6 +409,7 @@
## - "desktop-ui-migration-milestone-3": Special feature flag for desktop UI (Desktop >= 2026.2.0) ## - "desktop-ui-migration-milestone-3": Special feature flag for desktop UI (Desktop >= 2026.2.0)
## - "desktop-ui-migration-milestone-4": Special feature flag for desktop UI (Desktop >= 2026.2.0) ## - "desktop-ui-migration-milestone-4": Special feature flag for desktop UI (Desktop >= 2026.2.0)
## - "enable-basic-auth-response": Enable HTTP Basic Auth autofill in the browser extension (Browser >= 2026.9.0) ## - "enable-basic-auth-response": Enable HTTP Basic Auth autofill in the browser extension (Browser >= 2026.9.0)
## - "undetermined-cipher-scenario-logic": Enable the rewritten add/update login notification triggering logic in the browser extension (Browser >= 2026.2.0)
# EXPERIMENTAL_CLIENT_FEATURE_FLAGS= # EXPERIMENTAL_CLIENT_FEATURE_FLAGS=
## Require new device emails. When a user logs in an email is required to be sent. ## Require new device emails. When a user logs in an email is required to be sent.

26
src/api/admin.rs

@ -905,23 +905,23 @@ mod tests {
fn validate_web_vault_compare() { fn validate_web_vault_compare() {
// web_vault_compare(active, latest) // web_vault_compare(active, latest)
// Test normal versions // Test normal versions
assert!(web_vault_compare("2025.12.0", "2025.12.1") == -1); assert_eq!(web_vault_compare("2025.12.0", "2025.12.1"), -1);
assert!(web_vault_compare("2025.12.1", "2025.12.1") == 0); assert_eq!(web_vault_compare("2025.12.1", "2025.12.1"), 0);
assert!(web_vault_compare("2025.12.2", "2025.12.1") == 1); assert_eq!(web_vault_compare("2025.12.2", "2025.12.1"), 1);
// Test patched/+build.n versions // Test patched/+build.n versions
// Newer latest version // Newer latest version
assert!(web_vault_compare("2025.12.0+build.1", "2025.12.1") == -1); assert_eq!(web_vault_compare("2025.12.0+build.1", "2025.12.1"), -1);
assert!(web_vault_compare("2025.12.1", "2025.12.1+build.1") == -1); assert_eq!(web_vault_compare("2025.12.1", "2025.12.1+build.1"), -1);
assert!(web_vault_compare("2025.12.0+build.1", "2025.12.1+build.1") == -1); assert_eq!(web_vault_compare("2025.12.0+build.1", "2025.12.1+build.1"), -1);
assert!(web_vault_compare("2025.12.1+build.1", "2025.12.1+build.2") == -1); assert_eq!(web_vault_compare("2025.12.1+build.1", "2025.12.1+build.2"), -1);
// Equal versions // Equal versions
assert!(web_vault_compare("2025.12.1+build.1", "2025.12.1+build.1") == 0); assert_eq!(web_vault_compare("2025.12.1+build.1", "2025.12.1+build.1"), 0);
assert!(web_vault_compare("2025.12.2+build.2", "2025.12.2+build.2") == 0); assert_eq!(web_vault_compare("2025.12.2+build.2", "2025.12.2+build.2"), 0);
// Newer active version // Newer active version
assert!(web_vault_compare("2025.12.1+build.1", "2025.12.1") == 1); assert_eq!(web_vault_compare("2025.12.1+build.1", "2025.12.1"), 1);
assert!(web_vault_compare("2025.12.2", "2025.12.1+build.1") == 1); assert_eq!(web_vault_compare("2025.12.2", "2025.12.1+build.1"), 1);
assert!(web_vault_compare("2025.12.2+build.1", "2025.12.1+build.1") == 1); assert_eq!(web_vault_compare("2025.12.2+build.1", "2025.12.1+build.1"), 1);
assert!(web_vault_compare("2025.12.1+build.3", "2025.12.1+build.2") == 1); assert_eq!(web_vault_compare("2025.12.1+build.3", "2025.12.1+build.2"), 1);
} }
} }

1
src/api/web.rs

@ -89,6 +89,7 @@ fn vaultwarden_css() -> EtagCached<Css<String>> {
// Else, there is either no cache, or reload_templates is true and we need to rebuild the CSS // Else, there is either no cache, or reload_templates is true and we need to rebuild the CSS
let css_options = json!({ let css_options = json!({
"email_change_allowed": CONFIG.email_change_allowed(),
"emergency_access_allowed": CONFIG.emergency_access_allowed(), "emergency_access_allowed": CONFIG.emergency_access_allowed(),
"load_user_scss": true, "load_user_scss": true,
"mail_2fa_enabled": CONFIG._enable_email_2fa(), "mail_2fa_enabled": CONFIG._enable_email_2fa(),

2
src/config.rs

@ -1427,6 +1427,7 @@ pub const SUPPORTED_FEATURE_FLAGS: &[&str] = &[
"pm-5594-safari-account-switching", "pm-5594-safari-account-switching",
"pm-32413-multi-client-password-management", "pm-32413-multi-client-password-management",
// Autofill Team // Autofill Team
"undetermined-cipher-scenario-logic",
"enable-basic-auth-response", "enable-basic-auth-response",
"ssh-agent", "ssh-agent",
"ssh-agent-v2", "ssh-agent-v2",
@ -1434,6 +1435,7 @@ pub const SUPPORTED_FEATURE_FLAGS: &[&str] = &[
"ssh-key-vault-item", "ssh-key-vault-item",
"pm-25373-windows-biometrics-v2", "pm-25373-windows-biometrics-v2",
"pm-26340-linux-biometrics-v2", "pm-26340-linux-biometrics-v2",
"windows-native-credential-sync",
// Mobile Team // Mobile Team
"anon-addy-self-host-alias", "anon-addy-self-host-alias",
"simple-login-self-host-alias", "simple-login-self-host-alias",

18
src/http_client.rs

@ -466,7 +466,7 @@ mod tests {
#[test] #[test]
fn dotted_decimal_loopback_normalizes() { fn dotted_decimal_loopback_normalizes() {
let ip = parse_to_ip("127.0.0.1").unwrap(); let ip = parse_to_ip("127.0.0.1").unwrap();
assert_eq!(ip, IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))); assert_eq!(ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
assert!(!is_global_hardcoded(ip)); assert!(!is_global_hardcoded(ip));
} }
@ -474,21 +474,21 @@ mod tests {
fn single_decimal_loopback_normalizes() { fn single_decimal_loopback_normalizes() {
// 127.0.0.1 == 2130706433 // 127.0.0.1 == 2130706433
let ip = parse_to_ip("2130706433").unwrap(); let ip = parse_to_ip("2130706433").unwrap();
assert_eq!(ip, IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))); assert_eq!(ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
assert!(!is_global_hardcoded(ip)); assert!(!is_global_hardcoded(ip));
} }
#[test] #[test]
fn hex_loopback_normalizes() { fn hex_loopback_normalizes() {
let ip = parse_to_ip("0x7f000001").unwrap(); let ip = parse_to_ip("0x7f000001").unwrap();
assert_eq!(ip, IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))); assert_eq!(ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
assert!(!is_global_hardcoded(ip)); assert!(!is_global_hardcoded(ip));
} }
#[test] #[test]
fn dotted_hex_loopback_normalizes() { fn dotted_hex_loopback_normalizes() {
let ip = parse_to_ip("0x7f.0.0.1").unwrap(); let ip = parse_to_ip("0x7f.0.0.1").unwrap();
assert_eq!(ip, IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))); assert_eq!(ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
assert!(!is_global_hardcoded(ip)); assert!(!is_global_hardcoded(ip));
} }
@ -496,14 +496,14 @@ mod tests {
fn octal_loopback_normalizes() { fn octal_loopback_normalizes() {
// 017700000001 == 127.0.0.1 // 017700000001 == 127.0.0.1
let ip = parse_to_ip("017700000001").unwrap(); let ip = parse_to_ip("017700000001").unwrap();
assert_eq!(ip, IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))); assert_eq!(ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
assert!(!is_global_hardcoded(ip)); assert!(!is_global_hardcoded(ip));
} }
#[test] #[test]
fn dotted_octal_loopback_normalizes() { fn dotted_octal_loopback_normalizes() {
let ip = parse_to_ip("0177.0.0.01").unwrap(); let ip = parse_to_ip("0177.0.0.01").unwrap();
assert_eq!(ip, IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))); assert_eq!(ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
assert!(!is_global_hardcoded(ip)); assert!(!is_global_hardcoded(ip));
} }
@ -535,19 +535,19 @@ mod tests {
#[test] #[test]
fn get_valid_host_normalizes_decimal_int() { fn get_valid_host_normalizes_decimal_int() {
let h = get_valid_host("2130706433").expect("valid"); let h = get_valid_host("2130706433").expect("valid");
assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::new(127, 0, 0, 1))); assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST));
} }
#[test] #[test]
fn get_valid_host_normalizes_hex() { fn get_valid_host_normalizes_hex() {
let h = get_valid_host("0x7f000001").expect("valid"); let h = get_valid_host("0x7f000001").expect("valid");
assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::new(127, 0, 0, 1))); assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST));
} }
#[test] #[test]
fn get_valid_host_normalizes_octal() { fn get_valid_host_normalizes_octal() {
let h = get_valid_host("017700000001").expect("valid"); let h = get_valid_host("017700000001").expect("valid");
assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::new(127, 0, 0, 1))); assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST));
} }
// === // ===

7
src/static/templates/scss/vaultwarden.scss.hbs

@ -220,6 +220,13 @@ auth-input-password > form > bit-form-field:nth-child(4) {
@extend %vw-hide; @extend %vw-hide;
} }
{{/unless}} {{/unless}}
{{#unless email_change_allowed}}
/* Hide the whole `Change email` section, including its heading, if not allowed */
div:has(> app-change-email) {
@extend %vw-hide;
}
{{/unless}}
/**** End Dynamic Vaultwarden Changes ****/ /**** End Dynamic Vaultwarden Changes ****/
/**** Include a special user stylesheet for custom changes ****/ /**** Include a special user stylesheet for custom changes ****/
{{#if load_user_scss}} {{#if load_user_scss}}

14
src/util.rs

@ -943,15 +943,15 @@ mod tests {
use std::net::IpAddr; use std::net::IpAddr;
#[test] #[test]
#[ignore] #[ignore = "exhaustive IPv4 check is too slow for the regular test suite"]
fn test_ipv4_global() { fn test_ipv4_global() {
for a in 0..u8::MAX { for a in 0..u8::MAX {
println!("Iter: {}/255", a); println!("Iter: {a}/255");
for b in 0..u8::MAX { for b in 0..u8::MAX {
for c in 0..u8::MAX { for c in 0..u8::MAX {
for d in 0..u8::MAX { for d in 0..u8::MAX {
let ip = IpAddr::V4(std::net::Ipv4Addr::new(a, b, c, d)); let ip = IpAddr::V4(std::net::Ipv4Addr::new(a, b, c, d));
assert_eq!(ip.is_global(), is_global_hardcoded(ip), "IP mismatch: {}", ip) assert_eq!(ip.is_global(), is_global_hardcoded(ip), "IP mismatch: {ip}");
} }
} }
} }
@ -959,15 +959,15 @@ mod tests {
} }
#[test] #[test]
#[ignore] #[ignore = "random IPv6 check is too slow for the regular test suite"]
fn test_ipv6_global() { fn test_ipv6_global() {
use rand::Rng; use rand::RngExt;
std::thread::scope(|s| { std::thread::scope(|s| {
for t in 0..16 { for t in 0..16 {
let handle = s.spawn(move || { let _handle = s.spawn(move || {
let mut v = [0u8; 16]; let mut v = [0u8; 16];
let mut rng = rand::thread_rng(); let mut rng = rand::rng();
for i in 0..20 { for i in 0..20 {
println!("Thread {t} Iter: {i}/50"); println!("Thread {t} Iter: {i}/50");

Loading…
Cancel
Save