mirror of
https://github.com/rustdesk/hbb_common.git
synced 2026-04-02 22:16:18 +00:00
fix(password): do not update salt when updating permanent password
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -1267,9 +1267,11 @@ impl Config {
|
|||||||
config: &mut Config,
|
config: &mut Config,
|
||||||
password: &str,
|
password: &str,
|
||||||
) -> String {
|
) -> String {
|
||||||
// Rotate salt on permanent password updates so the verifier changes even if the user
|
// Keep salt stable for user-initiated permanent password updates.
|
||||||
// reuses a previous password. (No-op updates are handled in `set_permanent_password()`.)
|
// Salt should only change when service->user sync updates storage and salt as a pair.
|
||||||
config.salt = Config::get_auto_password(DEFAULT_SALT_LEN);
|
if config.salt.is_empty() {
|
||||||
|
config.salt = Config::get_auto_password(DEFAULT_SALT_LEN);
|
||||||
|
}
|
||||||
let h1 = compute_permanent_password_h1(password, &config.salt);
|
let h1 = compute_permanent_password_h1(password, &config.salt);
|
||||||
encode_permanent_password_storage_from_h1(&h1)
|
encode_permanent_password_storage_from_h1(&h1)
|
||||||
}
|
}
|
||||||
@@ -1379,6 +1381,10 @@ impl Config {
|
|||||||
.map_or(false, |v| !v.is_empty())
|
.map_or(false, |v| !v.is_empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn has_local_permanent_password() -> bool {
|
||||||
|
!CONFIG.read().unwrap().password.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_salt(salt: &str) {
|
pub fn set_salt(salt: &str) {
|
||||||
let mut config = CONFIG.write().unwrap();
|
let mut config = CONFIG.write().unwrap();
|
||||||
if salt == config.salt {
|
if salt == config.salt {
|
||||||
|
|||||||
Reference in New Issue
Block a user