Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read user and password from authinfo.gpg #2

Open
nightscape opened this issue Apr 27, 2020 · 4 comments
Open

Read user and password from authinfo.gpg #2

nightscape opened this issue Apr 27, 2020 · 4 comments

Comments

@nightscape
Copy link

Hi @Kungsgeten,

is it possible to read the credentials from the .authinfo.gpg.
I'm an Elisp noob, therefore I can't tell from the code...

Thanks for creating this! Looking forward to integrating it into my Building A Second Brain workflow 😄

@Kungsgeten
Copy link
Owner

Hi! There's nothing built into the package that makes this possible. I haven't used .authinfo much myself, since I use the same Emacs configuration on both Windows and Linux. Maybe this site can help: https://www.masteringemacs.org/article/keeping-secrets-in-emacs-gnupg-auth-sources

@nightscape
Copy link
Author

nightscape commented Apr 27, 2020

Ok, figured it out with the help of https://emacs.stackexchange.com/a/8072/11825
This can be done by putting the following line into ~/.authinfo.gpg

machine hypothes.is login your_hypothesis_user secret "your_hypothesis_token"

and the following code in your Emacs config

(with-eval-after-load 'random-mode
  (require 'auth-source)
  (let ((auth (nth 0 (auth-source-search :host "hypothes.is"
                                         :requires '(user secret)))))
    (setq hypothesis-token (funcall (plist-get auth :secret))
          hypothesis-username (plist-get auth :user))))

or in Doom Emacs in ~/.doom.d/config.el

(after! hypothesis
  (require 'auth-source)
  (let ((auth (nth 0 (auth-source-search :host "hypothes.is"
                                         :requires '(user secret)))))
    (setq hypothesis-token (funcall (plist-get auth :secret))
          hypothesis-username (plist-get auth :user))))

Should this be put in the README?

@Kungsgeten
Copy link
Owner

I personally don't feel like it should be in the README since storing personal information seems like a general concept, rather than something specific to this package. Also it feels a bit strange to recommend something regarding safety when I don't understand it myself.

@nightscape
Copy link
Author

Some Emacs packages seem to come with auth-source integration by default, e.g.
org-jira and Magit, that's why I got to ask in the first place.
But I don't mind either way, as it works for me now and my password is safely encrypted in my .authinfo.gpg 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants