Add 1pass-signin command

This commit is contained in:
Jeremy Dormitzer 2019-04-23 10:26:31 -04:00
parent 6023baf8b6
commit cc6f013282

View File

@ -2773,3 +2773,30 @@ The aws-mfa command:
(general-def kubernetes-overview-mode-map "m" #'aws-mfa))
#+END_SRC
** 1Password
#+BEGIN_SRC emacs-lisp
(defvar op-token nil
"The 1Password session token")
(defun 1pass-signin ()
(interactive)
(let* ((signin-address "team-lolatravel.1password.com")
(signin-email "jeremydormitzer@lola.com")
(secret-key (password-store-get "1pass-lola-secret-key"))
(master-password (password-store-get "team-lolatravel.1password.com"))
(proc (start-process "op-signin" "*op-signin*"
"op" "signin" signin-address signin-email secret-key "--output=raw")))
(set-process-sentinel
proc
(make-process-sentinel
(lambda ()
(setq op-token
(with-current-buffer "*op-signin*"
(goto-char (- (point-max) 1))
(buffer-substring-no-properties (line-beginning-position) (line-end-position))))
(message (format "Signed in to 1Password with session token %s" op-token))
(kill-buffer "*op-signin*"))
(lambda ()
(message "1Password signin failed, check *op-signin* buffer for details"))))
(process-send-string proc (concat master-password "\n"))))
#+END_SRC