fix(host,gui): the Connect page's keys: never replaced, no admin, revoked by id, a quoted command, a leftover file said

Make the key asks the server first and never replaces: a live key whose copy
is missing here may be in use, so it is said in words and left alone. A
page-made key carries read, write and post, not admin (the connect command
keeps its scopes). Revoke names the key's id, so a stale row cannot end a
newer key of the same name; a revoke that leaves the token file says the key
is dead and where the file is. The copyable command is single-quoted for a
POSIX shell and PowerShell, and refused when cmd.exe would act on a part.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 10:23:11 -07:00
1 parent e34b18ec73
commit fd847701e8
8 files changed
+588 -55

No files matched your search

+10 -3
View File
@@ -142,6 +142,7 @@ impl ledger_gui::owner::Owner for ViewerOwner {
.tokens
.into_iter()
.map(|t| TokenRow {
id: t.id,
book: t.book,
name: t.name,
scopes: t.scopes,
@@ -151,8 +152,8 @@ impl ledger_gui::owner::Owner for ViewerOwner {
Ok(Roster { assistants, tokens })
}
fn serve_revoke(&self, book: &str, name: &str) -> Result<String, String> {
self.server.revoke_token(book, name)
fn serve_revoke(&self, book: &str, name: &str, id: &str) -> Result<String, String> {
self.server.revoke_token(book, name, id)
}
fn command_line(&self, words: &[&str]) -> Result<String, String> {
@@ -160,7 +161,13 @@ impl ledger_gui::owner::Owner for ViewerOwner {
}
fn make_key(&self, book: &str) -> Result<bool, String> {
ledger_host::commands::ensure_key(&self.common, book)
use ledger_store::auth::Scope;
// What a page-made key may do: read, draft and post; never admin.
ledger_host::commands::ensure_key(
&self.common,
book,
&[Scope::Read, Scope::Write, Scope::Post],
)
}
fn close_books(&self) -> Result<String, String> {