From 651fd624d13ed47f83cb99b6ee5a083cb1ac9353 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Wed, 2 Mar 2022 17:45:28 +0100 Subject: [PATCH] `bitwarden--login-password' now asks for user input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- bitwarden.el | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bitwarden.el b/bitwarden.el index a0eb670..6668407 100644 --- a/bitwarden.el +++ b/bitwarden.el @@ -173,10 +173,10 @@ This macro is largely copied from Tecosaur’s 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