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

add keyring support #82

Open
zabbal opened this issue Aug 11, 2014 · 4 comments
Open

add keyring support #82

zabbal opened this issue Aug 11, 2014 · 4 comments
Milestone

Comments

@zabbal
Copy link

zabbal commented Aug 11, 2014

Emacs have built-in interface for gnome-keyring and kwallet called secrets:
(require 'secrets)

Would be great if circe would support it so credentials could be obtained from secure, portable, DE-agnostic and program-independent storage.

@jorgenschaefer jorgenschaefer added this to the Release v1.4 milestone Aug 12, 2014
@jorgenschaefer jorgenschaefer modified the milestones: Release v1.4, Release 1.5 Aug 26, 2014
@jorgenschaefer jorgenschaefer modified the milestones: Release v1.5, v1.6 Dec 12, 2014
@jorgenschaefer jorgenschaefer modified the milestones: v1.7, v1.6 Feb 21, 2015
@jorgenschaefer jorgenschaefer modified the milestones: v1.8, v1.7 Apr 4, 2015
@jorgenschaefer jorgenschaefer modified the milestones: Backlog, v2.1 Nov 1, 2015
@Thaodan
Copy link
Contributor

Thaodan commented Jun 4, 2022

Hey I was working on this a few days ago.

A more convenient now days is to use an auth-source retriever if the password, sasl-password or nickserv-password is not passed to the circe-network.

If I understand correctly the way to do this would be to set the default of those to the auth-source wrapper function.
However this would work better if the function in those contexts get more of the parameters from the circe-network.

I have a prototype version of this based on the existing function of ghub here:

  (defun circe--ident (username network)
    (format "%s^%s" username network))
  (defun circe--auth-source-get (keys &rest spec)
    (declare (indent 1))
    (let ((plist (car (apply #'auth-source-search
                             (append spec (list :max 1))))))
      (mapcar (lambda (k)
                (plist-get plist k))
              keys)))
  (defun circe-pass-get (host user &optional network)
    "fooobar
    \fn(fn host user &optional network)"
    (auth-source-forget (list :host host :user user :max 1))
    (when network
      (setq user (circe--ident user network)))
    (let ((match (car (circe--auth-source-get (list :secret)
                        :host host :user user))))
      (cond ((null match)
             (error "Auth source empty for %s %s %s" host user network))
            ((functionp match)
             (funcall match)) (t match))))

Right now this helper can be used as lambda when specifying any pass entry like this:

:pass (lambda (host) (circe-pass-get host user "<user>"))

Now any auth-source such as secrets can be used to retrieve pass for circe.

@wasamasa
Copy link
Collaborator

wasamasa commented Jun 4, 2022

If you need extra context, the function is called with the process buffer current and has access to buffer-local variables such as circe-network (see the section it's defined in for more of those).

Generally, I'm against adding keyring support due to the horrible auth-source.el API (your example forgets a cached item for no apparent reason): https://old.reddit.com/r/emacs/comments/8lvda6/is_authsource_from_the_dark_side/

@Thaodan
Copy link
Contributor

Thaodan commented Jun 4, 2022 via email

@wasamasa
Copy link
Collaborator

wasamasa commented Jun 4, 2022

The first point has been addressed, some new backends and minor improvements have been added, but the API is still the same. secrets.el seems to use a saner approach, but isn't nearly as useful. I just resort to calling pass, far less of a headache.

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

No branches or pull requests

4 participants