`bitwarden--login-password' now asks for user input

Instead of storing the user’s Bitwarden password in a variable, it is
better to ask the user through `read-passwd' for their password when
`bitwarden--login-password' is non-nil.
The other options of storing the password in the authinfo file, in an
environment variable or in a file are still available.
This commit is contained in:
Lucien Cartier-Tilet 2022-03-02 17:45:28 +01:00
parent b2813060a0
commit 651fd624d1
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -173,10 +173,10 @@ This macro is largely copied from Tecosaurs screenshot.el"
(read-string "Email address: ")) (read-string "Email address: "))
(bitwarden--define-infix (bitwarden--define-infix
"-p" "login-password" "Password of the user" "-p" "login-password" "Use a direct password input."
'string "0.1.0" 'boolean "0.1.0"
nil nil
(read-string "Password: ")) (not bitwarden--login-password))
(bitwarden--define-infix (bitwarden--define-infix
"-s" "login-sso" "Log in with Single-Sign On" "-s" "login-sso" "Log in with Single-Sign On"
@ -238,18 +238,18 @@ the authinfo source."
(defun bitwarden--get-password () (defun bitwarden--get-password ()
"Get password or password source. "Get password or password source.
By order of preference, retrieve the password from either the By order of preference, retrieve the password from the user if
Elisp variable `bitwarden--password', from the environment file `bitwarden--login-password' is non-nil, from the environment file
designated by the variable `bitwarden--passwordenv', by the file designated by the variable `bitwarden--login-passwordenv', by the
designated by the variable `bitwarden-passwordfile', or from the file designated by the variable `bitwarden--login-passwordfile',
authinfo source." or from the authinfo source."
(cond (cond
((not (bitwarden--empty-or-nil bitwarden-password))
bitwarden--password)
((! (bitwarden--empty-or-nil bitwarden--passwordenv)) ((! (bitwarden--empty-or-nil bitwarden--passwordenv))
`("--passwordenv" ,bitwarden--passwordenv)) `("--passwordenv" ,bitwarden--passwordenv))
((! (bitwarden--set-passwordfile bitwarden--passwordfile)) ((! (bitwarden--set-passwordfile bitwarden--passwordfile))
`("--passwordfile" ,bitwarden--passwordfile)) `("--passwordfile" ,bitwarden--passwordfile))
(bitwarden--login-password
(read-passwd "Bitwarden Password: "))
(t (funcall (t (funcall
(plist-get (plist-get
(car (auth-source-search :max 1 (car (auth-source-search :max 1