this post was submitted on 04 Mar 2024
13 points (100.0% liked)

Emacs

2201 readers
1 users here now

Our infinitely powerful editor.

founded 4 years ago
MODERATORS
13
submitted 8 months ago* (last edited 8 months ago) by [email protected] to c/[email protected]
 

Hey gang!

So I've used gopass for awhile now, and Emacs for longer.

I was wondering if any of you here interact with gopass via Emacs with auth-source or something similar.

The main reason I ask is because I'm wanting to finally use Emacs for other things, such as an IRC client and making more use of Magit, and even writing with 750words.

A lot of my passwords are stored with gopass, and the structure isn't always the same for stores. For instance:

| Forums
|-- Gentoo
|-- Some other forum
|
| Email Host
|--  [email protected]
|---- password
|---- recovery codes
|
| Employer Name
|-- Some program we use at work
|---- [email protected]
|
| Some app
|-- My User Name

Maybe this structure for a password store is a no-no, though it's not a big deal to move things around.

Any tips? I've seen auth-source-gopass, but that doesn't provide any interaction with selection of passwords or creation of passwords, I think.

I've look at that mentioned library some and writing an auth-source backend doesn't seem too involved, but maybe I don't necessarily have to with auth-source.

EDIT:

A potential configuration that others might use:

(require 'consult)
(require 'auth-source-pass)

(use-package pass
  :requires password-store
  :preface
  (defvar consult:pass-source
    `(:name "Passwords"
      :narrow ?<                     ;; maybe you want something else for narrow?
      :face pass-mode-directory-face ;; maybe you want to use a different face?
      :category pass
      :enabled
      ,(lambda ()
         (auth-source-pass-file-name-p auth-source-pass-filename))
      :items ,#'password-store-list)
    "Consult source for passwords with (go)pass.")

  (defun consult:pass (arg pass)
    "Stolen from Doom Emacs.
https://github.com/doomemacs/doomemacs/blob/master/modules/tools/pass/autoload/consult.el"
    (interactive
     (list current-prefix-arg
           (progn
             (require 'consult)
             (consult--read consult:pass-source
                            :prompt "(Go)Pass: "
                            :sort nil
                            :require-match t
                            :category 'pass))))
    (funcall (if arg
                 #'password-store-url
               #'password-store-copy)
             pass))
  :custom
  (password-store-executable (executable-find "gopass"))
  (auth-source-pass-filename
   (or (getenv "PASSWORD_STORE_DIR")
       (expand-file-name "~/.local/share/gopass/stores/root")))
  :config
  (auth-source-pass-enable))
top 5 comments
sorted by: hot top controversial new old
[–] [email protected] 2 points 8 months ago (1 children)

I guess I’m supposed to know what gopass is. Is it this? https://github.com/gopasspw/gopass

[–] [email protected] 3 points 8 months ago

Yes, should've mentioned that in my post.

[–] [email protected] 1 points 8 months ago* (last edited 8 months ago) (1 children)

I am only a casual user of it but pass.el (also in MELPA) works for me. This is for the original pass but since gopass is highly compatible it seems to work for that too. It uses password-store.el under the hood so you'd do something like (setq password-store-executable "/path/to/gopass") to point it at the right executable.

[–] [email protected] 1 points 8 months ago (1 children)

Interesting. Do you enable the auth-source backend for pass as well?

Funnily enough, it seems Nicholas Petton (creator of the pass.el library) contributed to this. :)

[–] [email protected] 1 points 8 months ago

I don't use that but looking at the source it looks like it's accessing the password store directly by reading the gpg files so I'd expect it to work the same regardless of the pass implementation used.