[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/url-http-ntlm 30e6148 36/42: url-http-ntlm: Avoid calcu
From: |
Stefan Monnier |
Subject: |
[elpa] externals/url-http-ntlm 30e6148 36/42: url-http-ntlm: Avoid calculating responses twice |
Date: |
Sat, 28 Nov 2020 17:19:49 -0500 (EST) |
branch: externals/url-http-ntlm
commit 30e614829bf27902df0a4a330fe14945f17604e0
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>
url-http-ntlm: Avoid calculating responses twice
* packages/url-http-ntlm/url-http-ntlm.el
(url-http-ntlm--get-stage): Update docstring.
(url-ntlm-auth): Return immediately if prompt is not t. Update
docstring.
---
url-http-ntlm.el | 74 +++++++++++++++++++++++++++++---------------------------
1 file changed, 39 insertions(+), 35 deletions(-)
diff --git a/url-http-ntlm.el b/url-http-ntlm.el
index 58622ad..3946151 100644
--- a/url-http-ntlm.el
+++ b/url-http-ntlm.el
@@ -148,16 +148,9 @@ request to the host in URL's server slot."
(defun url-http-ntlm--get-stage (args)
"Determine what stage of the NTLM handshake we are at.
-PROMPT and ARGS come from `url-ntlm-auth''s caller,
-`url-get-authentication'. Their meaning depends on the current
-implementation - this function is well and truly coupled.
-
-`url-get-authentication' calls `url-ntlm-auth' once when checking
-what authentication schemes are supported (PROMPT and ARGS are
-nil), and then twice for every stage of the handshake: the first
-time PROMPT is nil, the second, t; ARGS contains the server
-response's \"WWW-Authenticate\" header, munged by
-`url-parse-args'."
+ARGS comes from `url-ntlm-auth''s caller,
+`url-get-authentication'. Its meaning depends on the current
+implementation -- this function is well and truly coupled."
(cl-declare (special url-http-extra-headers))
(let* ((response-rxp "^NTLM TlRMTVNTUAADAAA")
(challenge-rxp "^TLRMTVNTUAACAAA")
@@ -275,36 +268,47 @@ two-step process, this function expects to be called
twice, first
to generate the NTLM type 1 message (request), then to respond to
the server's type 2 message (challenge) with a suitable response.
-PROMPT, OVERWRITE, and REALM are ignored.
+url-get-authentication' calls `url-ntlm-auth' once when checking
+what authentication schemes are supported (PROMPT and ARGS are
+nil), and then twice for every stage of the handshake: the first
+time PROMPT is nil, the second, t; ARGS contains the server
+response's \"WWW-Authenticate\" header, munged by
+`url-parse-args'.
+
+If PROMPT is not t then this function just returns nil. This is
+to avoid calculating responses twice.
+
+OVERWRITE and REALM are ignored.
ARGS is expected to contain the WWW-Authentication header from
the server's last response. These are used by
`url-http-get-stage' to determine what stage we are at."
- (url-http-ntlm--ensure-keepalive)
- (let* ((user-url (url-http-ntlm--ensure-user url))
- (stage (url-http-ntlm--get-stage args)))
- (url-debug 'url-http-ntlm "Stage: %s" stage)
- (cl-case stage
- ;; NTLM Type 1 message: the request
- (:request
- (url-http-ntlm--detect-loop user-url)
- (cl-destructuring-bind (&optional key hash)
- (url-http-ntlm--authorization user-url nil realm)
- (when (cl-third key)
- (url-http-ntlm--string
- (ntlm-build-auth-request (cl-second key) (cl-third key))))))
- ;; NTLM Type 3 message: the response
- (:response
- (url-http-ntlm--detect-loop user-url)
- (let ((challenge (url-http-ntlm--get-challenge)))
- (cl-destructuring-bind (key hash)
+ (when (eq prompt t)
+ (url-http-ntlm--ensure-keepalive)
+ (let* ((user-url (url-http-ntlm--ensure-user url))
+ (stage (url-http-ntlm--get-stage args)))
+ (url-debug 'url-http-ntlm "Stage: %s" stage)
+ (cl-case stage
+ ;; NTLM Type 1 message: the request
+ (:request
+ (url-http-ntlm--detect-loop user-url)
+ (cl-destructuring-bind (&optional key hash)
(url-http-ntlm--authorization user-url nil realm)
- (url-http-ntlm--string
- (ntlm-build-auth-response challenge
- (cl-second key)
- hash)))))
- (:error
- (url-http-ntlm--authorization user-url :clear)))))
+ (when (cl-third key)
+ (url-http-ntlm--string
+ (ntlm-build-auth-request (cl-second key) (cl-third key))))))
+ ;; NTLM Type 3 message: the response
+ (:response
+ (url-http-ntlm--detect-loop user-url)
+ (let ((challenge (url-http-ntlm--get-challenge)))
+ (cl-destructuring-bind (key hash)
+ (url-http-ntlm--authorization user-url nil realm)
+ (url-http-ntlm--string
+ (ntlm-build-auth-response challenge
+ (cl-second key)
+ hash)))))
+ (:error
+ (url-http-ntlm--authorization user-url :clear))))))
;;; Register `url-ntlm-auth' HTTP authentication method.
- [elpa] externals/url-http-ntlm 0dad577 08/42: url-http-ntlm.el: Update copyright owner and years, (continued)
- [elpa] externals/url-http-ntlm 0dad577 08/42: url-http-ntlm.el: Update copyright owner and years, Stefan Monnier, 2020/11/28
- [elpa] externals/url-http-ntlm 9813aea 19/42: url-http-ntlm: Prevent infinite loops, Stefan Monnier, 2020/11/28
- [elpa] externals/url-http-ntlm be85e0a 21/42: url-http-ntlm: Declare url-http-extra-headers special, Stefan Monnier, 2020/11/28
- [elpa] externals/url-http-ntlm 790fbd3 25/42: url-http-ntlm: Change spelling of authorization function, Stefan Monnier, 2020/11/28
- [elpa] externals/url-http-ntlm 2aed8ca 22/42: url-http-ntlm: Autoload url-ntlm-auth and its registration, Stefan Monnier, 2020/11/28
- [elpa] externals/url-http-ntlm c2db685 28/42: url-http-ntlm: Add `url-debug' debugging messages, Stefan Monnier, 2020/11/28
- [elpa] externals/url-http-ntlm 544d008 27/42: url-http-ntlm: Shorten first line of some docstrings, Stefan Monnier, 2020/11/28
- [elpa] externals/url-http-ntlm 9d142fc 32/42: url-http-ntlm.el: Bump version to 2.0.1, Stefan Monnier, 2020/11/28
- [elpa] externals/url-http-ntlm 2a29445 34/42: url-http-ntlm: Bump version to 2.0.2, Stefan Monnier, 2020/11/28
- [elpa] externals/url-http-ntlm da855fa 33/42: Remove url-http-ntlm-parse-header-NN.MM.el files, Stefan Monnier, 2020/11/28
- [elpa] externals/url-http-ntlm 30e6148 36/42: url-http-ntlm: Avoid calculating responses twice,
Stefan Monnier <=
- [elpa] externals/url-http-ntlm a2f8a2d 38/42: url-http-ntlm: Bump version to 2.0.3, Stefan Monnier, 2020/11/28
- [elpa] externals/url-http-ntlm 9ab4d58 41/42: * copyright_exceptions: Update for new uni-confusables/gen-confusables.el, Stefan Monnier, 2020/11/28