emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Loading credentials from login keyring


From: Thomas Hisch
Subject: Loading credentials from login keyring
Date: Tue, 29 Dec 2020 20:33:13 +0100

I'm the author of an elisp pkg [1] that talks via a REST API with a
server. For determining the credentials I use
`auth-source-user-and-password` in this elisp pkg.

Currently I store my credentials in an .authinfo file, but I
would like to read them from the keyring, since I already have
credentials for the service in the Login keyring.

I created the credentials using the python-keyring [2] pkg using the command

`keyring set hostname username`

The above command creates an entry in the Login keyring that has the following schema (output of `M-x secrets-show-secrets`)

 `-[-] Password for ’thomas.hisch’ on ’hostname’
    |-  password:    ********** [Show password]
    |-  application: Python keyring library
    |-  service:     hostname
    |-  username:    thomas.hisch
    `-  xdg:schema:  org.freedesktop.Secret.Generic

The problem now is that `auth-source-user-and-password` doesn't find the credentials in the "Login" keyring, i.e.,

(let ((auth-sources '("secrets:Login")))
  (auth-source-user-and-password "hostname"))

returns nil. The reason for this is that `auth-source-user-and-password` searches for an entry with a plist key :host and not with the key :service.

I know that I can manually pass the search spec to `auth-source-search`,
but I want to keep the auth code in my pkg as high-level as
possible. I also don't want to break anything for
users that use different auth-sources.

Is the implementation of auth-source.el, e.g. `auth-source-user-and-password`, supposed
to support reading of secrets stored in a keyring, which are not created by emacs?

Best regards,
Thomas

[1] https://github.com/thisch/gerrit.el
[2] https://keyring.readthedocs.io/en/latest/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]