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