Let an admin delete a vault, behind their own password
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
The web interface could create a vault and never remove one, so the only
way to undo a mistake was the CLI. There is now a Delete link on every
vault you administer, leading to a page that says what is about to go —
owner, versions stored, grants pointing at it — and asks for your
account password before it goes.
The gate is re-authentication, not a confirmation checkbox. A session
token is enough to read and write a vault; it should not be enough to
erase every version of one, because a session is what an unlocked
laptop leaves lying around. The one-time code is required too when the
account has one enrolled.
It lives in confirmDeletion, so the rule holds wherever deletion is
reachable: DELETE /api/v1/databases/{id} now takes {password, totp?}
and answers 401 without it, and keeporg db -delete prompts. That is a
breaking change to the endpoint, which is why the server goes to 0.7.0
and the desktop clients to 0.4.0.
An account that signs in only through an identity provider has no
password to type. Rather than lock those deployments out of deleting
anything, they confirm by typing the vault's exact name — the weaker
gate, and deliberately the fallback.
Deleting takes the record, its grants, every stored version and the key
a merge vault left with the server, and tells the watchers over SSE.
Copies already in people's mirror directories stay where they are: the
server stops tracking a vault, it does not reach into anybody's home
directory.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
967d9c0e2e
commit
e0977a9241
+15
-2
@@ -412,7 +412,8 @@ func cmdDB(ctx context.Context, args []string) error {
|
||||
"merge strategy: merge, server-wins, client-wins or manual")
|
||||
id := fs.String("id", "", "database id, for -strategy, -rename or -delete")
|
||||
rename := fs.String("rename", "", "new name for -id")
|
||||
del := fs.Bool("delete", false, "delete the database given by -id")
|
||||
del := fs.Bool("delete", false,
|
||||
"delete the database given by -id, every stored version of it included")
|
||||
storePassword := fs.Bool("store-password", false,
|
||||
"give the server this vault's password so it can merge the vault")
|
||||
forgetPassword := fs.Bool("forget-password", false,
|
||||
@@ -463,7 +464,19 @@ func cmdDB(ctx context.Context, args []string) error {
|
||||
}
|
||||
fmt.Printf("%s now uses %s\n", db.Name, db.MergeStrategy)
|
||||
case *id != "" && *del:
|
||||
if err := api.DeleteDatabase(ctx, *id); err != nil {
|
||||
password, perr := readPassword("Your account password: ")
|
||||
if perr != nil {
|
||||
return perr
|
||||
}
|
||||
err := api.DeleteDatabase(ctx, *id, password, "")
|
||||
if client.Code(err) == "totp_required" || client.Code(err) == "totp_invalid" {
|
||||
code, cerr := prompt("One-time code: ")
|
||||
if cerr != nil {
|
||||
return cerr
|
||||
}
|
||||
err = api.DeleteDatabase(ctx, *id, password, code)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("deleted on the server; local files were left in place")
|
||||
|
||||
Reference in New Issue
Block a user