feat(bw): scoped vault sessions, bw-shell, vw picker, Enter guard #66

Merged
jmz merged 1 commit from feat/bw-scoped-sessions into master 2026-11-25 22:55:24 +00:00
Owner

Three related changes so the vault is open only as long as needed, unlocked with one OnlyKey slot press.

Session model (dot_config/shell/bitwarden.sh): BW_SESSION is a bearer key. Before this change bw-unlock and the vw-* helpers exported it into the login shell and never locked again.

  • Every bw-*/vw-* helper now unlocks for one call and locks afterwards. _bw_scoped runs in a subshell whose EXIT trap locks, even on Ctrl-C.
  • bw-shell [minutes] holds one session for a batch of commands and locks on exit or after BW_SHELL_MINUTES (15). bw-unlock opens one, and bwrun <cmd> scopes any command.
  • Starship shows vault→HH:MM while a bw-shell is open.

vw picker (dot_config/zsh/vaultwarden.zsh): vw [-q|-k] [query] unlocks once per run.

  • Keys are vim-like, Telescope-style: it opens in insert mode to search. Esc switches to normal mode with j/k, g/G and u/p/t/l/n/f to copy; i or / goes back to search, q quits.
  • Enter copies the username, waits for the password, then for the TOTP code if there is one. -q quits after one copy; -k returns to the list until q.
  • The clipboard auto-clears. The list and preview carry metadata only. The whole run is capped at VW_PICK_MINUTES, then killed and locked.

Enter guard (dot_config/zsh/accept-guard.zsh): a command line whose first word zsh can't run is discarded instead of executed. A mistimed OnlyKey press at a shell prompt then never puts the master password into zsh history, atuin (synced) or tmux-resurrect's pane captures. Ctrl-Y restores a typo, and ZSH_ACCEPT_GUARD=0 turns it off. It chains to the existing accept-line, so syntax highlighting keeps working.

Tested against a stub bw, a fake fzf and a fake clipboard (harness kept outside the repo):

  • session scope and locking, also after a failing or interrupted command;
  • 36 guard cases plus a live tmux check that history stays clean;
  • 9 picker scenarios plus a live tmux run with real fzf.
    No secret reaches stderr, the list or the preview.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XMf4ELq1Q12cmKnPuwJz2x

Three related changes so the vault is open only as long as needed, unlocked with one OnlyKey slot press. **Session model** (`dot_config/shell/bitwarden.sh`): `BW_SESSION` is a bearer key. Before this change `bw-unlock` and the `vw-*` helpers exported it into the login shell and never locked again. - Every `bw-*`/`vw-*` helper now unlocks for one call and locks afterwards. `_bw_scoped` runs in a subshell whose EXIT trap locks, even on Ctrl-C. - `bw-shell [minutes]` holds one session for a batch of commands and locks on exit or after `BW_SHELL_MINUTES` (15). `bw-unlock` opens one, and `bwrun <cmd>` scopes any command. - Starship shows `vault→HH:MM` while a bw-shell is open. **`vw` picker** (`dot_config/zsh/vaultwarden.zsh`): `vw [-q|-k] [query]` unlocks once per run. - Keys are vim-like, Telescope-style: it opens in insert mode to search. Esc switches to normal mode with j/k, g/G and u/p/t/l/n/f to copy; i or / goes back to search, q quits. - Enter copies the username, waits for the password, then for the TOTP code if there is one. `-q` quits after one copy; `-k` returns to the list until q. - The clipboard auto-clears. The list and preview carry metadata only. The whole run is capped at `VW_PICK_MINUTES`, then killed and locked. **Enter guard** (`dot_config/zsh/accept-guard.zsh`): a command line whose first word zsh can't run is discarded instead of executed. A mistimed OnlyKey press at a shell prompt then never puts the master password into zsh history, atuin (synced) or tmux-resurrect's pane captures. Ctrl-Y restores a typo, and `ZSH_ACCEPT_GUARD=0` turns it off. It chains to the existing accept-line, so syntax highlighting keeps working. Tested against a stub bw, a fake fzf and a fake clipboard (harness kept outside the repo): - session scope and locking, also after a failing or interrupted command; - 36 guard cases plus a live tmux check that history stays clean; - 9 picker scenarios plus a live tmux run with real fzf. No secret reaches stderr, the list or the preview. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XMf4ELq1Q12cmKnPuwJz2x
feat(bw): scoped vault sessions, bw-shell, vw picker, Enter guard
All checks were successful
ci / gate (pull_request) Successful in 2m18s
6cef2da602
BW_SESSION is a bearer key: with it and data.json the whole vault decrypts
offline, with no expiry until `bw lock`. bw-unlock and the vw-* helpers
exported it into the login shell and never locked again, so every child
process (build tools, agents) could read the vault for the rest of the day.

Sessions: every bw-*/vw-* helper now unlocks for that one call and locks
afterwards (_bw_scoped, a subshell whose EXIT trap locks even on Ctrl-C);
with the master password in an OnlyKey slot that is one button press.
`bw-shell [minutes]` opens a subshell holding one session for a batch of
commands, locked on exit or after BW_SHELL_MINUTES (15); bw-unlock opens
one; `bwrun <cmd>` scopes any command. Starship shows "vault→HH:MM" while a
bw-shell is open. Login hint updated for the SSO Vaultwarden.

vw [-q|-k] [query]: fzf picker with one unlock per run. Telescope-style
vim keys (insert mode to search; Esc: j/k, g/G, u/p/t/l/n/f copy, i or /
back, q quit). Enter copies the username, waits for the password, then
for the TOTP code if the entry has one; -q quits after one copy, -k
returns to the list until q. Clipboard auto-clears (VW_CLIP_TTL); list
and preview carry metadata only; the whole run is capped at
VW_PICK_MINUTES and then killed and locked.

accept-guard.zsh: a command line whose first word zsh cannot run is
discarded instead of executed, so an OnlyKey slot pressed at a shell
prompt never puts the master password into zsh history, atuin (synced) or
tmux-resurrect's pane captures. Ctrl-Y restores a typo; ZSH_ACCEPT_GUARD=0
disables it. Chains to the existing accept-line (syntax highlighting).

Tested against a stub bw, a fake fzf and a fake clipboard: session scope
and locking (also after a failing or interrupted command), 36 guard
cases, 9 picker scenarios plus a live tmux run with real fzf; no secret
reaches stderr, the list or the preview.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XMf4ELq1Q12cmKnPuwJz2x
jmz merged commit 6cef2da602 into master 2026-11-25 22:55:24 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
public/dotfiles-public!66
No description provided.