No Description

Sean Farley 9471e63b7a readme: add example macro for async processes (closes #8) 4 years ago
LICENSE 80822a3285 license: add gpl3 7 years ago
README.org 9471e63b7a readme: add example macro for async processes (closes #8) 4 years ago
bitwarden.el 23fc8f5e78 dialog: check for being logged in 4 years ago

README.org

README

Emacs Bitwarden

A Bitwarden command wrapper for Emacs.

Installation

To use this package you will need the Bitwarden CLI.

Automatic unlock

Bitwarden has a concept of locking which is different from logging in. For two-factor authentication, this means that only logging in will require your 2fa token.

As a convenience, you can store your master password in your OS keychain and use the bitwarden-automatic-unlock variable. For example, to temporarily set the auth-source to the macos keychain and then query that,

(setq bitwarden-automatic-unlock
      (let* ((auth-sources '(macos-keychain-internet))
             (matches (auth-source-search :user "sean@farley.io"
                                          :host "bitwarden.farley.in"
                                          :require '(:secret)
                                          :max 1))
             (entry (nth 0 matches)))
        (plist-get entry :secret)))

auth-source

There is read-only support for auth-source as well. You can run bitwarden-auth-source-enable to enable it. For example,

(auth-source-search :host "github.com")

will return all logins that match github.com.

async support

For certain emacs tasks (e.g. github modeline), emacs will run the process asynchronously which means a new emacs process. For this reason, this bitwarden wrapper will need to be a macro so that the session is preserved. Here is an one such way to do that:

(defmacro smf/bitwarden-init ()
  "Needs to be a macro due to async.

Async doesn't load your entire config (for performance reasons)
so this needs to be a macro and added to async hooks."
  `(progn
     (require 'bitwarden nil t)
     (setq bitwarden-user "sean@farley.io"

           bitwarden-automatic-unlock (let* ((auth-sources
                                              '(macos-keychain-internet))
                                             (matches (auth-source-search
                                                       :user "sean@farley.io"
                                                       :host "bitwarden.farley.io"
                                                       :require '(:secret)
                                                       :max 1))
                                             (entry (nth 0 matches)))
                                        (plist-get entry :secret)))
     (bitwarden-auth-source-enable)))

And then add it to async hooks as such,

(add-hook 'doom-modeline-before-github-fetch-notification-hook
          (lambda () (smf/bitwarden-init)))"