[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/url-http-oauth 38157dfb3a 09/24: Reduce overloading of
From: |
Thomas Fitzsimmons |
Subject: |
[elpa] externals/url-http-oauth 38157dfb3a 09/24: Reduce overloading of "register" |
Date: |
Mon, 8 May 2023 21:10:45 -0400 (EDT) |
branch: externals/url-http-oauth
commit 38157dfb3adf3f7fd44ecaa7eed738fff0b22606
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Reduce overloading of "register"
* url-http-oauth.el: Add Usage section to Commentary.
(url-http-oauth--interposed): Rename.
(url-http-oauth-configuration): Update references.
(url-http-oauth-interpose): Rename. Update references.
(url-http-oauth-ignore): Rename.
(url-http-oauth-get-bearer): Update error message.
---
url-http-oauth.el | 43 +++++++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/url-http-oauth.el b/url-http-oauth.el
index 4852bab2f3..5ccf6488dc 100644
--- a/url-http-oauth.el
+++ b/url-http-oauth.el
@@ -26,13 +26,17 @@
;; Installation:
;;
;; M-x package-install RET url-http-oauth RET
+;;
+;; Usage:
+;;
+;; See url-http-oauth-demo.el.
;;; Code:
(require 'url-auth)
(require 'url-http)
(require 'url-util)
-(defvar url-http-oauth--registered-oauth-urls nil
+(defvar url-http-oauth--interposed nil
"A hash table mapping URL strings to lists of OAuth 2.0 configuration.")
(defun url-http-oauth-url-string (url)
@@ -46,7 +50,7 @@
(defun url-http-oauth-configuration (url)
"Return a configuration list if URL needs OAuth 2.0, nil otherwise.
URL is either a URL object or a URL string."
- (when url-http-oauth--registered-oauth-urls
+ (when url-http-oauth--interposed
(let* ((url-no-query (url-parse-make-urlobj
(url-type url)
nil nil
@@ -55,19 +59,19 @@ URL is either a URL object or a URL string."
(car (url-path-and-query url))
nil nil t))
(key (url-http-oauth-url-string url-no-query)))
- (gethash key url-http-oauth--registered-oauth-urls))))
+ (gethash key url-http-oauth--interposed))))
;; Maybe if RFC 8414, "OAuth 2.0 Authorization Server Metadata",
;; catches on, authorization-url and access-token-url can be made
;; optional and their values retrieved automatically. As of early
;; 2023, RFC 8414 is not consistently implemented yet.
-(defun url-http-oauth-register-resource (url
- authorization-url
- access-token-url
- client-identifier
- &optional
- client-secret-required)
- "Tell Emacs that to access URL, it needs to use OAuth 2.0.
+(defun url-http-oauth-interpose (url
+ authorization-url
+ access-token-url
+ client-identifier
+ &optional
+ client-secret-required)
+ "Arrange for Emacs to use OAuth 2.0 to access URL.
URL will be accessed by Emacs's `url' library with a suitable
\"Authorization\" header containing \"Bearer <token>\".
AUTHORIZATION-URL and ACCESS-TOKEN-URL will be used to acquire
@@ -76,9 +80,8 @@ AUTHORIZATION-URL and ACCESS-TOKEN-URL are either objects or
strings. CLIENT-IDENTIFIER is a string identifying an Emacs
library or mode to the server. CLIENT-SECRET-REQUIRED is the
symbol `prompt' if a client secret is required, nil otherwise."
- (unless url-http-oauth--registered-oauth-urls
- (setq url-http-oauth--registered-oauth-urls
- (make-hash-table :test #'equal)))
+ (unless url-http-oauth--interposed
+ (setq url-http-oauth--interposed (make-hash-table :test #'equal)))
(let ((key (url-http-oauth-url-string url))
(authorization (url-http-oauth-url-string authorization-url))
(access-token-object (url-http-oauth-url-object access-token-url)))
@@ -88,14 +91,14 @@ symbol `prompt' if a client secret is required, nil
otherwise."
((eq client-secret-required nil) nil)
(t (error
"Unrecognized client-secret-required value"))))
- url-http-oauth--registered-oauth-urls)))
+ url-http-oauth--interposed)))
-(defun url-http-oauth-unregister-resource (url)
- "Tell Emacs not to use OAuth 2.0 when accessing URL.
+(defun url-http-oauth-ignore (url)
+ "Arrange for Emacs not to use OAuth 2.0 when accessing URL.
+This function does the opposite of `url-http-oauth-interpose'.
URL is either an objects or a string."
- (when url-http-oauth--registered-oauth-urls
- (remhash (url-http-oauth-url-string url)
- url-http-oauth--registered-oauth-urls)))
+ (when url-http-oauth--interposed
+ (remhash (url-http-oauth-url-string url) url-http-oauth--interposed)))
(defvar url-http-response-status)
(defvar auth-source-creation-prompts)
@@ -195,7 +198,7 @@ URL is a parsed object."
(or bearer-current
(let ((url-list (url-http-oauth-configuration url)))
(unless url-list
- (error "%s is not registered with url-http-oauth"
+ (error "%s is not interposed by url-http-oauth"
(url-http-oauth-url-string url)))
(let* ((response-url
(read-from-minibuffer
- [elpa] externals/url-http-oauth 3b3f9fe53f 12/24: Support extra arguments on authorization URL, (continued)
- [elpa] externals/url-http-oauth 3b3f9fe53f 12/24: Support extra arguments on authorization URL, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth 8601d89d43 18/24: Complete regexp, list and token refresh design, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth ee73bb0450 19/24: Make functions private, fix some bugs, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth 7e825a8765 21/24: Allow per-provider user-agent interaction function, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth 9b2af487e3 22/24: Use relative expiry time in seconds, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth d86dbb478d 23/24: Retest against sourcehut, fix new issues, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth 4441b79a9a 13/24: Remove explicit extra argument handling, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth 085d57961a 20/24: Make message formatting consistent, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth 0bf4a7633d 08/24: Complete confidential client support, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth b884e725af 05/24: Get basics working for Sourcehut, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth 38157dfb3a 09/24: Reduce overloading of "register",
Thomas Fitzsimmons <=
- [elpa] externals/url-http-oauth e1408ed406 02/24: Implement provider registration, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth f5b953197b 15/24: Fix auth-source-search for path and scope, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth 40c46af10c 24/24: Bump version to 0.8.0, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth e95f685771 06/24: Begin auth-source implementation, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth 1ecb40b545 17/24: Make some adjustments based on testing, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth fcb5929654 16/24: Fix auth-source lookup conflicts and config cdrs, Thomas Fitzsimmons, 2023/05/08