;;; url-auth.el --- Uniform Resource Locator authorization modules
-;; Copyright (C) 1996, 1997, 1998, 1999, 2004, 2005, 2006, 2007,
-;; 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2014 Free Software Foundation, Inc.
;; Keywords: comm, data, processes, hypermedia
(require 'url-vars)
(require 'url-parse)
(autoload 'url-warn "url")
-(autoload 'auth-source-user-or-password "auth-source")
+(autoload 'auth-source-search "auth-source")
(defsubst url-auth-user-prompt (url realm)
"String to usefully prompt for a username."
(file (url-filename href))
(user (url-user href))
(pass (url-password href))
+ (enable-recursive-minibuffers t) ; for url-handler-mode (bug#10298)
byserv retval data)
(setq server (format "%s:%d" server port)
file (cond
(cond
((and prompt (not byserv))
(setq user (or
- (auth-source-user-or-password "login" server type)
+ (url-do-auth-source-search server type :user)
(read-string (url-auth-user-prompt url realm)
(or user (user-real-login-name))))
pass (or
- (auth-source-user-or-password "password" server type)
+ (url-do-auth-source-search server type :secret)
(read-passwd "Password: " nil (or pass ""))))
(set url-basic-auth-storage
(cons (list server
(if (or (and (not retval) prompt) overwrite)
(progn
(setq user (or
- (auth-source-user-or-password "login" server type)
+ (url-do-auth-source-search server type :user)
(read-string (url-auth-user-prompt url realm)
(user-real-login-name)))
pass (or
- (auth-source-user-or-password "password" server type)
+ (url-do-auth-source-search server type :secret)
(read-passwd "Password: "))
retval (base64-encode-string (format "%s:%s" user pass))
byserv (assoc server (symbol-value url-basic-auth-storage)))
(type (url-type href))
(port (url-port href))
(file (url-filename href))
+ (enable-recursive-minibuffers t)
user pass byserv retval data)
(setq file (cond
(realm realm)
(cond
((and prompt (not byserv))
(setq user (or
- (auth-source-user-or-password "login" server type)
+ (url-do-auth-source-search server type :user)
(read-string (url-auth-user-prompt url realm)
(user-real-login-name)))
pass (or
- (auth-source-user-or-password "password" server type)
+ (url-do-auth-source-search server type :secret)
(read-passwd "Password: "))
url-digest-auth-storage
(cons (list server
(if overwrite
(if (and (not retval) prompt)
(setq user (or
- (auth-source-user-or-password "login" server type)
+ (url-do-auth-source-search server type :user)
(read-string (url-auth-user-prompt url realm)
(user-real-login-name)))
pass (or
- (auth-source-user-or-password "password" server type)
+ (url-do-auth-source-search server type :secret)
(read-passwd "Password: "))
retval (setq retval
(cons user
"A list of the registered authorization schemes and various and sundry
information associated with them.")
+(defun url-do-auth-source-search (server type parameter)
+ (let* ((auth-info (auth-source-search :max 1 :host server :port type))
+ (auth-info (nth 0 auth-info))
+ (token (plist-get auth-info parameter))
+ (token (if (functionp token) (funcall token) token)))
+ token))
+
;;;###autoload
(defun url-get-authentication (url realm type prompt &optional args)
"Return an authorization string suitable for use in the WWW-Authenticate
(provide 'url-auth)
-;; arch-tag: 04058625-616d-44e4-9dbf-4b46b00b2a91
;;; url-auth.el ends here