Sfoglia il codice sorgente

Invalidate Session on bitwarden-lock

The Code before this just set the env variable `BW_SESSION` to nil.
This deletes the session key but leaves it valid, so it can basically
act as a master key.

This commit fixes this by actually calling the `bw lock` command
and setting the variable `BW_SESSION` to nil no matter if the vault is
still unlocked. This way the function can get called multiple times and
the vault stays locked and the env variable stays empty even when the
vault was locked by i.e. another terminal

Note vterm keeps the env variable until it is exited (not just minimized).
Marcel Wiesenhöfer 2 anni fa
parent
commit
93f40c57ae
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      bitwarden.el

+ 2 - 2
bitwarden.el

@@ -253,8 +253,8 @@ printed to minibuffer."
 (defun bitwarden-lock ()
 (defun bitwarden-lock ()
   "Lock the bw vault.  Does not ask for confirmation."
   "Lock the bw vault.  Does not ask for confirmation."
   (interactive)
   (interactive)
-  (when (bitwarden-unlocked-p)
-    (setenv "BW_SESSION" nil)))
+  (bitwarden-runcmd "lock")
+  (setenv "BW_SESSION" nil))
 
 
 (defun bitwarden-logout ()
 (defun bitwarden-logout ()
   "Log out bw.  Does not ask for confirmation."
   "Log out bw.  Does not ask for confirmation."