From: Ted Zlatanov <tzz@lifelogs.com>
To: Lynbech Christian <christian.lynbech@tietoenator.com>
Cc: ding@gnus.org, Emacs developers <emacs-devel@gnu.org>
Subject: auth-source glue in url-auth.el (was: nnrss and password handling)
Date: Fri, 09 May 2008 14:47:23 -0500 [thread overview]
Message-ID: <867ie3mf90.fsf_-_@lifelogs.com> (raw)
In-Reply-To: <86hce9wmgs.fsf@lifelogs.com> (Ted Zlatanov's message of "Thu, 10 Apr 2008 14:15:15 -0500")
[-- Attachment #1: Type: text/plain, Size: 1535 bytes --]
On Thu, 10 Apr 2008 14:15:15 -0500 Ted Zlatanov <tzz@lifelogs.com> wrote:
TZ> On Tue, 08 Apr 2008 10:25:51 +0200 Lynbech Christian <christian.lynbech@tietoenator.com> wrote:
LC> I am tracking some RSS feeds via nnrss which are password protected. Is
LC> there any way to hardwire these passwords, rather than having to type
LC> them in each time I start gnus?
LC> I was hoping for a mechanism akin to ~/.authinfo that for instance
LC> nnimap uses.
Hi Christian,
I set up auth-source glue for url-auth.el to achieve what you wanted.
The attached patch, which is not in CVS yet, is against today's Emacs
CVS. The Gnus CVS HEAD has the auth-source.el code you'll need,
including the comments on what to put in your authinfo/netrc file.
I tested against the sample feeds I found in
http://labs.silverorange.com/archives/2003/july/privaterss and this
seems to work fine:
(nnrss-fetch "http://labs.silverorange.com/local/solabs/rsstest/httpauth/rss_with_auth.xml")
Please test it yourself if you can.
The patch will match any realm when looking for a host/login/password
combination. I decided to go with a less flexible approach for
simplicity; I think it's rare to need more than one realm per host and
whoever does can always customize the underlying url-auth-* variables.
Emacs developers, please let me know if there's any problems with the
patch before I commit it into CVS. I'm being cautious because
url-auth.el is used by so many other libraries indirectly. If it's OK,
I'll commit it after the weekend.
Thanks
Ted
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: url-auth.auth-source.patch --]
[-- Type: text/x-diff, Size: 5303 bytes --]
? url-auth.auth-source.patch
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/url/ChangeLog,v
retrieving revision 1.156
diff -c -r1.156 ChangeLog
*** ChangeLog 6 May 2008 04:29:10 -0000 1.156
--- ChangeLog 9 May 2008 19:31:48 -0000
***************
*** 1,3 ****
--- 1,10 ----
+ 2008-05-09 Teodor Zlatanov <tzz@lifelogs.com>
+
+ * url-auth.el: Add autoload cookie for
+ `auth-source-user-or-password'.
+ (url-basic-auth, url-digest-auth): Use it with any realm,
+ overriding the user name and password before the prompt.
+
2008-04-28 Juanma Barranquero <lekktu@gmail.com>
* url-vars.el (url-load-hook): Fix typo in docstring.
Index: url-auth.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/url/url-auth.el,v
retrieving revision 1.22
diff -c -r1.22 url-auth.el
*** url-auth.el 6 May 2008 04:29:10 -0000 1.22
--- url-auth.el 9 May 2008 19:31:48 -0000
***************
*** 26,31 ****
--- 26,34 ----
(require 'url-parse)
(autoload 'url-warn "url")
+ (eval-and-compile
+ (autoload 'auth-source-user-or-password "auth-source"))
+
(defsubst url-auth-user-prompt (url realm)
"String to usefully prompt for a username."
(concat "Username [for "
***************
*** 64,69 ****
--- 67,73 ----
(url-generic-parse-url url)
url))
(server (url-host href))
+ (type (url-type href))
(port (url-port href))
(file (url-filename href))
(user (url-user href))
***************
*** 79,87 ****
(symbol-value url-basic-auth-storage))))
(cond
((and prompt (not byserv))
! (setq user (read-string (url-auth-user-prompt url realm)
! (or user (user-real-login-name)))
! pass (read-passwd "Password: " nil (or pass "")))
(set url-basic-auth-storage
(cons (list server
(cons file
--- 83,95 ----
(symbol-value url-basic-auth-storage))))
(cond
((and prompt (not byserv))
! (setq user (or
! (auth-source-user-or-password "login" server type)
! (read-string (url-auth-user-prompt url realm)
! (or user (user-real-login-name))))
! pass (or
! (auth-source-user-or-password "password" server type)
! (read-passwd "Password: " nil (or pass ""))))
(set url-basic-auth-storage
(cons (list server
(cons file
***************
*** 103,111 ****
(setq byserv (cdr byserv))))
(if (or (and (not retval) prompt) overwrite)
(progn
! (setq user (read-string (url-auth-user-prompt url realm)
! (user-real-login-name))
! pass (read-passwd "Password: ")
retval (base64-encode-string (format "%s:%s" user pass))
byserv (assoc server (symbol-value url-basic-auth-storage)))
(setcdr byserv
--- 111,123 ----
(setq byserv (cdr byserv))))
(if (or (and (not retval) prompt) overwrite)
(progn
! (setq user (or
! (auth-source-user-or-password "login" server type)
! (read-string (url-auth-user-prompt url realm)
! (user-real-login-name)))
! pass (or
! (auth-source-user-or-password "password" server type)
! (read-passwd "Password: "))
retval (base64-encode-string (format "%s:%s" user pass))
byserv (assoc server (symbol-value url-basic-auth-storage)))
(setcdr byserv
***************
*** 150,155 ****
--- 162,168 ----
(url-generic-parse-url url)
url))
(server (url-host href))
+ (type (url-type href))
(port (url-port href))
(file (url-filename href))
user pass byserv retval data)
***************
*** 161,169 ****
byserv (cdr-safe (assoc server url-digest-auth-storage)))
(cond
((and prompt (not byserv))
! (setq user (read-string (url-auth-user-prompt url realm)
! (user-real-login-name))
! pass (read-passwd "Password: ")
url-digest-auth-storage
(cons (list server
(cons file
--- 174,186 ----
byserv (cdr-safe (assoc server url-digest-auth-storage)))
(cond
((and prompt (not byserv))
! (setq user (or
! (auth-source-user-or-password "login" server type)
! (read-string (url-auth-user-prompt url realm)
! (user-real-login-name)))
! pass (or
! (auth-source-user-or-password "password" server type)
! (read-passwd "Password: "))
url-digest-auth-storage
(cons (list server
(cons file
***************
*** 188,196 ****
(setq byserv (cdr byserv))))
(if overwrite
(if (and (not retval) prompt)
! (setq user (read-string (url-auth-user-prompt url realm)
! (user-real-login-name))
! pass (read-passwd "Password: ")
retval (setq retval
(cons user
(url-digest-auth-create-key
--- 205,217 ----
(setq byserv (cdr byserv))))
(if overwrite
(if (and (not retval) prompt)
! (setq user (or
! (auth-source-user-or-password "login" server type)
! (read-string (url-auth-user-prompt url realm)
! (user-real-login-name)))
! pass (or
! (auth-source-user-or-password "password" server type)
! (read-passwd "Password: "))
retval (setq retval
(cons user
(url-digest-auth-create-key
next parent reply other threads:[~2008-05-09 19:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <ytqp8wzovjlc.fsf@ul000173.eu.tieto.com>
[not found] ` <86hce9wmgs.fsf@lifelogs.com>
2008-05-09 19:47 ` Ted Zlatanov [this message]
2008-05-09 21:19 ` auth-source glue added to smtpmail.el (was: auth-source glue in url-auth.el) Ted Zlatanov
2008-05-12 12:50 ` auth-source glue added to smtpmail.el Ted Zlatanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=867ie3mf90.fsf_-_@lifelogs.com \
--to=tzz@lifelogs.com \
--cc=christian.lynbech@tietoenator.com \
--cc=ding@gnus.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).