From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/66929 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: auth-source glue in url-auth.el (was: nnrss and password handling) Date: Fri, 09 May 2008 14:47:23 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <867ie3mf90.fsf_-_@lifelogs.com> References: <86hce9wmgs.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1210362263 18512 80.91.229.12 (9 May 2008 19:44:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 9 May 2008 19:44:23 +0000 (UTC) Cc: ding@gnus.org, Emacs developers To: Lynbech Christian Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 09 21:44:59 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JuYWY-0000iU-MB for ged-emacs-devel@m.gmane.org; Fri, 09 May 2008 21:44:59 +0200 Original-Received: from localhost ([127.0.0.1]:47586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JuYVq-0007rj-CU for ged-emacs-devel@m.gmane.org; Fri, 09 May 2008 15:44:14 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JuYVl-0007qs-I9 for emacs-devel@gnu.org; Fri, 09 May 2008 15:44:09 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JuYVk-0007qN-SX for emacs-devel@gnu.org; Fri, 09 May 2008 15:44:09 -0400 Original-Received: from [199.232.76.173] (port=53146 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JuYVk-0007qK-MS for emacs-devel@gnu.org; Fri, 09 May 2008 15:44:08 -0400 Original-Received: from mail.blockstar.com ([170.224.69.95]:40606) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JuYVk-0000dw-28 for emacs-devel@gnu.org; Fri, 09 May 2008 15:44:08 -0400 Original-Received: from tzlatanov-ubuntu-desktop.jumptrading.com (unknown [38.98.147.130]) by mail.blockstar.com (Postfix) with ESMTP id 3C1767D912A; Fri, 9 May 2008 12:56:17 -0700 (PDT) X-Hashcash: 1:20:080509:emacs-devel@gnu.org::9DwTxbwN/BbkEju5:0000000000000000000000000000000000000000001uyS X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" X-Hashcash: 1:20:080509:ding@gnus.org::MT3S+sT8VXiMcZR2:000000US X-Hashcash: 1:20:080509:christian.lynbech@tietoenator.com::nvvdMstOqi3kQ5K+:00000000000000000000000000001V5F In-Reply-To: <86hce9wmgs.fsf@lifelogs.com> (Ted Zlatanov's message of "Thu, 10 Apr 2008 14:15:15 -0500") User-Agent: Gnus/5.110009 (No Gnus v0.9) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:96899 gmane.emacs.gnus.general:66929 Archived-At: --=-=-= On Thu, 10 Apr 2008 14:15:15 -0500 Ted Zlatanov wrote: TZ> On Tue, 08 Apr 2008 10:25:51 +0200 Lynbech Christian 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=url-auth.auth-source.patch ? 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 + + * 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 * 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 --=-=-=--