1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-09-02 07:54:47 +00:00

#6163: Fix panic when SSO_MASTER_PASSWORD_POLICY is non-json

This commit is contained in:
Harshavardhan Musanalli 2025-08-17 20:34:57 +02:00
commit 1d3c0d4d9c

View file

@ -111,7 +111,14 @@ async fn master_password_policy(user: &User, conn: &DbConn) -> Value {
}
}))
} else if let Some(policy_str) = CONFIG.sso_master_password_policy().filter(|_| CONFIG.sso_enabled()) {
serde_json::from_str(&policy_str).unwrap_or(json!({}))
// Use a match statement to handle Ok and Err results gracefully.
match serde_json::from_str(&policy_str) {
Ok(val) => val,
Err(_) => {
warn!("Failed to parse sso_master_password_policy configuration string: {}", policy_str);
json!({})
},
}
} else {
json!({})
};