From 32afdcca8815331f1231fe9d8279ab9914197381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= Date: Thu, 8 Aug 2024 17:36:01 +0300 Subject: [PATCH] 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) --- lisp/url/url-auth.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/url/url-auth.el b/lisp/url/url-auth.el index c73047da6b3..d7d7701b364 100644 --- a/lisp/url/url-auth.el +++ b/lisp/url/url-auth.el @@ -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)))