Gnus development mailing list
 help / color / mirror / Atom feed
* nnrss and password handling
@ 2008-04-08  8:25 Lynbech Christian
  2008-04-08 16:37 ` Magnus Henoch
  2008-04-10 19:15 ` Ted Zlatanov
  0 siblings, 2 replies; 7+ messages in thread
From: Lynbech Christian @ 2008-04-08  8:25 UTC (permalink / raw)
  To: ding

I am tracking some RSS feeds via nnrss which are password protected. Is
there any way to hardwire these passwords, rather than having to type
them in each time I start gnus?

I was hoping for a mechanism akin to ~/.authinfo that for instance
nnimap uses.

                              -- Christian



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: nnrss and password handling
  2008-04-08  8:25 nnrss and password handling Lynbech Christian
@ 2008-04-08 16:37 ` Magnus Henoch
  2008-04-10 19:15 ` Ted Zlatanov
  1 sibling, 0 replies; 7+ messages in thread
From: Magnus Henoch @ 2008-04-08 16:37 UTC (permalink / raw)
  To: ding

Lynbech Christian <christian.lynbech@tietoenator.com> writes:

> I am tracking some RSS feeds via nnrss which are password protected. Is
> there any way to hardwire these passwords, rather than having to type
> them in each time I start gnus?

The variables url-basic-auth-storage or url-digest-auth-storage should
work.

Magnus




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: nnrss and password handling
  2008-04-08  8:25 nnrss and password handling Lynbech Christian
  2008-04-08 16:37 ` Magnus Henoch
@ 2008-04-10 19:15 ` Ted Zlatanov
  2008-04-11 11:27   ` Lynbech Christian
  2008-05-09 19:47   ` auth-source glue in url-auth.el (was: nnrss and password handling) Ted Zlatanov
  1 sibling, 2 replies; 7+ messages in thread
From: Ted Zlatanov @ 2008-04-10 19:15 UTC (permalink / raw)
  To: Lynbech Christian; +Cc: ding

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.

How does this look?

machine host://feed.xml username x password y protocol rss

I'll put it on my TODO list for auth-source.el and netrc.el if you agree
with the syntax.

I know the URL is not a machine, but extending the authinfo format is
tricky so I'd rather compromise.

Ted



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: nnrss and password handling
  2008-04-10 19:15 ` Ted Zlatanov
@ 2008-04-11 11:27   ` Lynbech Christian
  2008-05-09 19:47   ` auth-source glue in url-auth.el (was: nnrss and password handling) Ted Zlatanov
  1 sibling, 0 replies; 7+ messages in thread
From: Lynbech Christian @ 2008-04-11 11:27 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: ding

>>>>> "Ted" == Ted Zlatanov <tzz@lifelogs.com> writes:

Ted> machine host://feed.xml username x password y protocol rss

Looks fine to me, but Magnus Henochs suggestion of using the already
existing `url-basic-auth-storage' also works for me (thanks Magnus) so
while it could be usefull to align around ~/.authinfo, I have my fix.

                              -- Christian



^ permalink raw reply	[flat|nested] 7+ messages in thread

* auth-source glue in url-auth.el (was: nnrss and password handling)
  2008-04-10 19:15 ` Ted Zlatanov
  2008-04-11 11:27   ` Lynbech Christian
@ 2008-05-09 19:47   ` Ted Zlatanov
  2008-05-09 21:19     ` auth-source glue added to smtpmail.el (was: auth-source glue in url-auth.el) Ted Zlatanov
  1 sibling, 1 reply; 7+ messages in thread
From: Ted Zlatanov @ 2008-05-09 19:47 UTC (permalink / raw)
  To: Lynbech Christian; +Cc: ding, Emacs developers

[-- 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* auth-source glue added to smtpmail.el (was: auth-source glue in url-auth.el)
  2008-05-09 19:47   ` auth-source glue in url-auth.el (was: nnrss and password handling) Ted Zlatanov
@ 2008-05-09 21:19     ` Ted Zlatanov
  2008-05-12 12:50       ` auth-source glue added to smtpmail.el Ted Zlatanov
  0 siblings, 1 reply; 7+ messages in thread
From: Ted Zlatanov @ 2008-05-09 21:19 UTC (permalink / raw)
  To: ding, Emacs developers

[-- Attachment #1: Type: text/plain, Size: 808 bytes --]

On Fri, 09 May 2008 14:47:23 -0500 Ted Zlatanov <tzz@lifelogs.com> wrote: 

TZ> The [url-auth] patch will match any realm when looking for a
TZ> host/login/password combination.  I decided to go with a less
TZ> flexible approach for simplicity; I think it's rare to need more
TZ> than one realm per host and whoever does can always customize the
TZ> underlying url-auth-* variables.

TZ> Emacs developers, please let me know if there's any problems with the
TZ> patch before I commit it into CVS.  I'm being cautious because
TZ> url-auth.el is used by so many other libraries indirectly.  If it's OK,
TZ> I'll commit it after the weekend.

Similarly to the above, I've made a patch against smtpmail.el to support
auth-source.el, and will commit it after the weekend unless it's bad in
some way.

Thanks
Ted


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: smtpmail.auth-source.patch --]
[-- Type: text/x-diff, Size: 3443 bytes --]

Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.13703
diff -c -r1.13703 ChangeLog
*** ChangeLog	9 May 2008 20:17:48 -0000	1.13703
--- ChangeLog	9 May 2008 21:11:59 -0000
***************
*** 1,3 ****
--- 1,9 ----
+ 2008-05-09  Teodor Zlatanov  <tzz@lifelogs.com>
+ 
+ 	* mail/smtpmail.el: Add autoload for
+ 	`auth-source-user-or-password'.
+ 	(smtpmail-try-auth-methods): Use it.
+ 
  2008-05-09  Eric S. Raymond  <esr@snark.thyrsus.com>
  
  	* vc.el (vc-dir), vc-hooks.el: Tweak the VC directory bindings.
Index: mail/smtpmail.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/mail/smtpmail.el,v
retrieving revision 1.103
diff -c -r1.103 smtpmail.el
*** mail/smtpmail.el	6 May 2008 07:22:29 -0000	1.103
--- mail/smtpmail.el	9 May 2008 21:11:59 -0000
***************
*** 78,83 ****
--- 78,86 ----
  (autoload 'netrc-get "netrc")
  (autoload 'password-read "password-cache")
  
+ (eval-and-compile
+   (autoload 'auth-source-user-or-password "auth-source"))
+ 
  ;;;
  (defgroup smtpmail nil
    "SMTP protocol for sending mail."
***************
*** 539,555 ****
  (defun smtpmail-try-auth-methods (process supported-extensions host port)
    (let* ((mechs (cdr-safe (assoc 'auth supported-extensions)))
  	 (mech (car (smtpmail-intersection smtpmail-auth-supported mechs)))
! 	 (cred (if (stringp smtpmail-auth-credentials)
! 		   (let* ((netrc (netrc-parse smtpmail-auth-credentials))
!                           (port-name (format "%s" (or port "smtp")))
! 			  (hostentry (netrc-machine netrc host port-name
!                                                     port-name)))
!                      (when hostentry
!                        (list host port
!                              (netrc-get hostentry "login")
!                              (netrc-get hostentry "password"))))
! 		 (smtpmail-find-credentials
! 		  smtpmail-auth-credentials host port)))
  	 (prompt (when cred (format "SMTP password for %s:%s: "
  				    (smtpmail-cred-server cred)
  				    (smtpmail-cred-port cred))))
--- 542,567 ----
  (defun smtpmail-try-auth-methods (process supported-extensions host port)
    (let* ((mechs (cdr-safe (assoc 'auth supported-extensions)))
  	 (mech (car (smtpmail-intersection smtpmail-auth-supported mechs)))
! 	 (auth-user (auth-source-user-or-password 
! 		     "login" host (or port "smtp")))
! 	 (auth-pass (auth-source-user-or-password 
! 		     "password" host (or port "smtp")))
! 	 (cred (if (and auth-user auth-pass) ; try user-auth-* before netrc-*
! 		   (list host port auth-user auth-pass)
! 		 ;; else, if auth-source didn't return them...
! 		 (if (stringp smtpmail-auth-credentials)
! 		     (let* ((netrc (netrc-parse smtpmail-auth-credentials))
! 			    (port-name (format "%s" (or port "smtp")))
! 			    (hostentry (netrc-machine netrc host port-name
! 						      port-name)))
! 		       (when hostentry
! 			 (list host port
! 			       (netrc-get hostentry "login")
! 			       (netrc-get hostentry "password"))))
! 		   ;; else, try smtpmail-find-credentials since
! 		   ;; smtpmail-auth-credentials is not a string
! 		   (smtpmail-find-credentials
! 		    smtpmail-auth-credentials host port))))
  	 (prompt (when cred (format "SMTP password for %s:%s: "
  				    (smtpmail-cred-server cred)
  				    (smtpmail-cred-port cred))))

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: auth-source glue added to smtpmail.el
  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       ` Ted Zlatanov
  0 siblings, 0 replies; 7+ messages in thread
From: Ted Zlatanov @ 2008-05-12 12:50 UTC (permalink / raw)
  To: emacs-devel; +Cc: ding

On Fri, 09 May 2008 16:19:11 -0500 Ted Zlatanov <tzz@lifelogs.com> wrote: 

TZ> On Fri, 09 May 2008 14:47:23 -0500 Ted Zlatanov <tzz@lifelogs.com> wrote: 
TZ> The [url-auth] patch will match any realm when looking for a
TZ> host/login/password combination.  I decided to go with a less
TZ> flexible approach for simplicity; I think it's rare to need more
TZ> than one realm per host and whoever does can always customize the
TZ> underlying url-auth-* variables.

TZ> Emacs developers, please let me know if there's any problems with the
TZ> patch before I commit it into CVS.  I'm being cautious because
TZ> url-auth.el is used by so many other libraries indirectly.  If it's OK,
TZ> I'll commit it after the weekend.
...
TZ> Similarly to the above, I've made a patch against smtpmail.el to support
TZ> auth-source.el, and will commit it after the weekend unless it's bad in
TZ> some way.

I've comitted both patches to Emacs CVS, so now auth-sources will be
consulted for smtpmail.el and url*.el functions.  Please let me know if
you have any problems authenticating for SMTP or HTTP (basic or digest);
you can take a look at auth-source.el and make any suggestions you see
fit as well.

Thanks
Ted





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-05-12 12:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-08  8:25 nnrss and password handling Lynbech Christian
2008-04-08 16:37 ` Magnus Henoch
2008-04-10 19:15 ` Ted Zlatanov
2008-04-11 11:27   ` Lynbech Christian
2008-05-09 19:47   ` auth-source glue in url-auth.el (was: nnrss and password handling) Ted Zlatanov
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

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 NNTP newsgroup(s).