store: pin the unlocked-vault gate for change/export (L3)
This commit is contained in:
2 files changed
+38
No files matched your search
@@ -828,6 +828,11 @@ data/ desktop, metainfo, gschema (all `.in` templates), icons, re
|
||||
writing, so a typo cannot quietly create a second passphrase that opens only
|
||||
the new key. `change_passphrase` needs only the *new* one (we hold the keys)
|
||||
and re-encrypts every entry. `rename`/`forget` need no passphrase at all.
|
||||
**The unlocked vault is the authorisation (L3):** both `change_passphrase` and
|
||||
`export_user_key_encrypted` refuse a locked vault and require no re-entry of the
|
||||
current passphrase while it is open. That is deliberate — the control is the
|
||||
unlock plus the auto-lock timeout, not a second prompt — and is an accepted
|
||||
tradeoff recorded from the review, not an oversight.
|
||||
- **Auto-lock is a hard timeout since the unlock** (`lock-timeout`, default
|
||||
900 s, 0 = never), checked by a 30 s `glib` timer in `state.rs`, plus "Lock
|
||||
now". It is deliberately **not** an idle timer that request traffic resets — a
|
||||
|
||||
@@ -915,6 +915,39 @@ mod tests {
|
||||
assert!(second >= first);
|
||||
}
|
||||
|
||||
/// The unlocked vault **is** the authorisation for changing the passphrase
|
||||
/// and exporting a key (L3): both refuse a locked vault, and both work once
|
||||
/// it is open — deliberately with no second passphrase prompt.
|
||||
#[tokio::test]
|
||||
async fn a_locked_vault_cannot_change_its_passphrase_or_export() {
|
||||
let (path, store) = scratch();
|
||||
let key = store.generate_user_key("Work", "hunter2").await.expect("generate");
|
||||
store.lock();
|
||||
|
||||
assert!(
|
||||
store.change_passphrase("new").await.is_err(),
|
||||
"changing the passphrase needs an open vault"
|
||||
);
|
||||
assert!(
|
||||
store
|
||||
.export_user_key_encrypted(&key, "export-password")
|
||||
.await
|
||||
.is_err(),
|
||||
"exporting needs an open vault"
|
||||
);
|
||||
|
||||
// Both succeed once it is unlocked.
|
||||
store.unlock("hunter2").await.expect("unlock");
|
||||
store.change_passphrase("new").await.expect("change");
|
||||
assert!(
|
||||
store
|
||||
.export_user_key_encrypted(&key, "export-password")
|
||||
.await
|
||||
.is_ok()
|
||||
);
|
||||
let _ = std::fs::remove_dir_all(path.parent().unwrap());
|
||||
}
|
||||
|
||||
/// Two concurrent `add_user_key` calls leave a valid vault with both keys,
|
||||
/// and no temp file behind (M9).
|
||||
#[tokio::test]
|
||||
|
||||
Reference in new issue
Block a user