From 727042d46b05a74dbb956f1c1883b2f648cf0e97 Mon Sep 17 00:00:00 2001 From: Aakash N S <1560745+aakashns@users.noreply.github.com> Date: Mon, 19 Oct 2026 15:50:11 +0700 Subject: [PATCH] Change your password in Settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Settings has a new last row, "Change password". Enter or a click opens a dialog with three boxes: your current password, the new one, and the new one again. Tab moves between them, Enter goes on to the next empty one and then changes the password, and Esc cancels. A wrong current password, a confirmation that doesn't match, or a new password under 8 characters is said in the dialog, which stays open. It says "Changing the password…" while it works, then Settings says "Password changed." Your vault is re-encrypted in place with the new password. writui backs it up first and deletes the backup only once the vault has reopened with the new password, passed its integrity checks and still holds exactly what it did. If anything goes wrong, the vault is left (or put back from the backup) as it was, and the old password keeps working. If Touch ID is on, it's set up again for the new password on its own; if that can't be done, Touch ID is turned off and Settings says so. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 7 + docs/DECISIONS.md | 36 ++++ docs/PLAN.md | 4 +- docs/SPEC.md | 32 +++- src/tui/change_password.rs | 321 ++++++++++++++++++++++++++++++++++ src/tui/mod.rs | 97 ++++++++++- src/tui/settings.rs | 100 ++++++++++- src/tui/setup.rs | 5 +- src/tui/widgets.rs | 3 + src/vault/migrations.rs | 12 +- src/vault/mod.rs | 343 +++++++++++++++++++++++++++++++++++-- 13 files changed, 925 insertions(+), 39 deletions(-) create mode 100644 src/tui/change_password.rs diff --git a/Cargo.lock b/Cargo.lock index b82b665..8437f92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2937,7 +2937,7 @@ checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" [[package]] name = "writui" -version = "0.19.0" +version = "0.20.0" dependencies = [ "anyhow", "arboard", diff --git a/Cargo.toml b/Cargo.toml index ad7283d..13572d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "writui" -version = "0.19.0" +version = "0.20.0" edition = "2024" description = "A terminal writing app. No nonsense. Markdown. Local. Encrypted." license = "MIT" diff --git a/README.md b/README.md index 24af518..25f2f90 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,13 @@ fingerprint to the Mac turns it off until you next unlock with the password. Your vault's key, sealed so that only this Mac's Secure Enclave can open it after a fingerprint, is kept in `~/.config/writui/touch-id/`. +To change the password, open Settings and choose "Change password": type +your current password, then the new one twice. writui re-encrypts the +vault with the new password, keeping a backup of it until the vault has +reopened with the new password and passed its checks; if anything goes +wrong, the old password keeps working. Touch ID is set up again for the +new password on its own. + - **Posts** are listed with the most recently changed first. Open one with Enter or a click, start a new one with `n` (or Enter: "New" is highlighted when the list opens). The list's shortcuts are single keys, diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index 2533f9d..6e09fc3 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -785,3 +785,39 @@ copied in the meantime. The trade-off: "select, Cmd+C, then type over the selection" loses the copy (Cmd+X is the way to do that). Non-text clipboard contents (an image) can't be remembered, so selecting text replaces them. Tests use a per-thread fake clipboard rather than the real one. + +## Changing the password: rekey in place, checked end to end + +`Vault::change_password` checks the current password (Argon2 with the +file's salt must give the open vault's key), makes a new random salt and +the new password's key, takes a fingerprint (SHA-256 over the schema +version and every row of every table), backs the file up next to itself +(`writui.db.password-