From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thomas Hisch Newsgroups: gmane.emacs.devel Subject: Loading credentials from login keyring Date: Tue, 29 Dec 2020 20:33:13 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000cbe64005b79f7607" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18106"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 29 20:35:34 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kuKmM-0004Xw-EA for ged-emacs-devel@m.gmane-mx.org; Tue, 29 Dec 2020 20:35:34 +0100 Original-Received: from localhost ([::1]:60850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuKmL-0008VG-Ct for ged-emacs-devel@m.gmane-mx.org; Tue, 29 Dec 2020 14:35:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuKkL-0007Mr-NG for emacs-devel@gnu.org; Tue, 29 Dec 2020 14:33:30 -0500 Original-Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:44096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kuKkI-0001Vx-GI for emacs-devel@gnu.org; Tue, 29 Dec 2020 14:33:29 -0500 Original-Received: by mail-pg1-x52b.google.com with SMTP id p18so9752866pgm.11 for ; Tue, 29 Dec 2020 11:33:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=DQUpYNkieyOwzlG9Q0VvYqBNgqBHBQ52Ow3N1hg0mUs=; b=QIZs+Ra7wtE3iWnQ2Cdlp9mab7x2f3czvWA71IbmNOHo46kVDXk9ZEBJwnsy/0MGO2 sDz+aMUqh3KnZMZR7K/uRlkPvRj3RjjmG0DFwTZO5gC0SDk41CYPZI8FiCezgOPk6tTN 5fBGN1ksNSMEcZMAGK+aO2i9zIZ5NpYJTWfxH1vD22pg0e9ZG4NkutAJqk3sTK/dVnz0 CUEwR6qyUATX+vN8zBN5FazTY6n1NpOtoVw4o3FIO8uKR6ej5hazwLs3VeAT8Dr0jPrZ Wh1a28g9Ej4YQchIhVSWYbv3JtwKDo7UyT8MDe1xjI7N0Cn+kD80d/f3DbzitRcpIDwt a/kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=DQUpYNkieyOwzlG9Q0VvYqBNgqBHBQ52Ow3N1hg0mUs=; b=DhjnTEyJFvudfueF5pkJnBfC9p9pM8zO3tYeCy8oe9ckRm6xmOjk0bguTVA6F9TdrN TaJPtVGKG5yaIPIUTWSBHtm7oYBx9rOvZeCvTjrCZN+lN0hMXuuCjSyYIV+cQdf2GXSs Nz4Y6cLIlMDkuLZ5N5aGAs/5EAlu67gTTbxhbFaXeDd098S9few1eipVwD2Dyk137B8e jH6aPb52Oo08Li5IfpER5XCB4cSIck/HTpxli2wDFRoPh1aoR2cyjyxTD+Rs6/OhIQRg Axfpdws/N3X7XtdUSrJKEZ0bi5AQVWh2pHZ+KllrLaC6W6eHfoIKVCKBGvGtDVoquDe/ X4jA== X-Gm-Message-State: AOAM5308kQuA/vI+nIwUrAueC0KUKJWVbPL46mAMrF0TGLf9DuV7eB/F TfHXnV/xhd1f1jQOfeRG2dH5szoxExD/0a70jK7PDmB2KPE= X-Google-Smtp-Source: ABdhPJz1N1ogzidgATufV84DlqDsn2ITzGNX00haiMR+a7NuyI8iDApx1wBYsEAyDZyuwwJJLdwxKKWzV544qkf1vdI= X-Received: by 2002:a63:405:: with SMTP id 5mr49010211pge.44.1609270404309; Tue, 29 Dec 2020 11:33:24 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=t.hisch@gmail.com; helo=mail-pg1-x52b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:262087 Archived-At: --000000000000cbe64005b79f7607 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 comman= d `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 =E2=80=99thomas.hisch=E2=80=99 on =E2=80=99hostname=E2= =80=99 |- 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/ --000000000000cbe64005b79f7607 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'm the author of an elisp pkg [1] that talks via a RE= ST API with a
server. For determining the credentials I use
`auth-sou= rce-user-and-password` in this elisp pkg.

Currently I store my crede= ntials in an .authinfo file, but I
would like to read them from the keyr= ing, since I already have
credentials for the service in the Login keyri= ng.

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

`keyring set hostname username`

The above comman= d creates an entry in the Login keyring that has the following schema (outp= ut of `M-x secrets-show-secrets`)

=C2=A0`-[-] Password for =E2=80=99= thomas.hisch=E2=80=99 on =E2=80=99hostname=E2=80=99
=C2=A0 =C2=A0 |- =C2= =A0password: =C2=A0 =C2=A0********** [Show password]
=C2=A0 =C2=A0 |- = =C2=A0application: Python keyring library
=C2=A0 =C2=A0 |- =C2=A0service= : =C2=A0 =C2=A0 hostname
=C2=A0 =C2=A0 |- =C2=A0username: =C2=A0 =C2=A0t= homas.hisch
=C2=A0 =C2=A0 `- =C2=A0xdg:schema: =C2=A0org.freedesktop.Sec= ret.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")))
=C2=A0 (auth= -source-user-and-password "hostname"))

returns nil. The re= ason 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 t= o 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. `a= uth-source-user-and-password`, supposed
to support reading of sec= rets stored in a keyring, which are not created by emacs?
Best regards,
Thomas

--000000000000cbe64005b79f7607--