Forward user to auth-source inside url-basic-auth

* lisp/url/url-auth.el (url-basic-auth): Forward the user if
provided by the url or found by 'auth-source' when searching
for secrets.  Supplying 'auth-source' with the user when
matching secrets allows for more accurate retrieval and fixes
instances where the user enters an url that already contains
the user such as "user@host.de".  (Bug#72526)
This commit is contained in:
Björn Bidar 2024-08-08 17:36:01 +03:00 committed by Eli Zaretskii
parent f41614ad54
commit 32afdcca88

View file

@ -90,7 +90,7 @@ instead of the filename inheritance method."
(read-string (url-auth-user-prompt href realm)
(or user (user-real-login-name)))))
pass (or
(url-do-auth-source-search server type :secret)
(url-do-auth-source-search server type :secret user)
(and (url-interactive-p)
(read-passwd "Password: " nil (or pass "")))))
(setq server (format "%s:%d" server port))
@ -126,7 +126,7 @@ instead of the filename inheritance method."
(read-string (url-auth-user-prompt href realm)
(user-real-login-name))))
pass (or
(url-do-auth-source-search server type :secret)
(url-do-auth-source-search server type :secret user)
(and (url-interactive-p)
(read-passwd "Password: ")))
server (format "%s:%d" server port)
@ -461,8 +461,8 @@ challenge such as nonce and opaque."
"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))
(defun url-do-auth-source-search (server type parameter &optional user)
(let* ((auth-info (auth-source-search :max 1 :host server :port type :user user))
(auth-info (nth 0 auth-info))
(token (plist-get auth-info parameter))
(token (if (functionp token) (funcall token) token)))