[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/rt-liberation 4097a1c 24/68: * rt-liberation-rest.el: n
From: |
Yoni Rabkin |
Subject: |
[elpa] externals/rt-liberation 4097a1c 24/68: * rt-liberation-rest.el: new function rt-liber-rest-auth |
Date: |
Wed, 16 Dec 2020 12:11:08 -0500 (EST) |
branch: externals/rt-liberation
commit 4097a1cb4131e97fa13c62f7c8704358d2215395
Author: Yoni Rabkin <yoni@rabkins.net>
Commit: Yoni Rabkin <yoni@rabkins.net>
* rt-liberation-rest.el: new function rt-liber-rest-auth
This function checks for the REST credentials and if they are not there
it tries to grab them from auth-source.
---
rt-liberation-rest.el | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/rt-liberation-rest.el b/rt-liberation-rest.el
index 99f6ce9..6e3409d 100644
--- a/rt-liberation-rest.el
+++ b/rt-liberation-rest.el
@@ -45,10 +45,10 @@
(defvar rt-liber-rest-url ""
"URL of RT installation.")
-(defvar rt-liber-rest-username ""
+(defvar rt-liber-rest-username nil
"Username of RT account.")
-(defvar rt-liber-rest-password ""
+(defvar rt-liber-rest-password nil
"Password of RT account.")
(defvar rt-liber-rest-verbose-p t
@@ -65,6 +65,19 @@
(goto-char (point-max))
(insert str))))
+(defun rt-liber-rest-auth ()
+ "Try to get the REST credentials."
+ (if (and (stringp rt-liber-rest-username)
+ (stringp rt-liber-rest-password))
+ t
+ (message "rt-liber: no REST credentials set, so attempting auth-source")
+ (let ((auth-source-found-p
+ (auth-source-search :host "rt-liberation" :require '(:user :secret)
:create nil)))
+ (when (not auth-source-found-p)
+ (error "no auth-source found for login"))
+ (setq rt-liber-rest-password (funcall (plist-get (nth 0
auth-source-found-p) :secret))
+ rt-liber-rest-username (plist-get (nth 0 auth-source-found-p)
:user)))))
+
(defun rt-liber-rest-search-string (scheme url username password query)
"Return the search query string."
(let ((user (url-encode-url username))
@@ -124,11 +137,11 @@
str)
(setq str
(decode-coding-string
- (with-current-buffer response
- (buffer-substring-no-properties (point-min)
- (point-max)))
- 'utf-8))
-
+ (with-current-buffer response
+ (buffer-substring-no-properties (point-min)
+ (point-max)))
+ 'utf-8))
+
(rt-liber-rest-write-debug
(format "outgoing rest call -->\n%s\n<-- incoming\n%s\n" url str))
str)))
@@ -138,6 +151,7 @@
(when (or (not (stringp op))
(not (stringp query-string)))
(error "bad arguments"))
+ (rt-liber-rest-auth)
(cond ((string= op "ls")
(rt-liber-rest-call
(rt-liber-rest-search-string rt-liber-rest-scheme
@@ -215,6 +229,7 @@
"Run edit comment to set FIELD to VALUE."
(message "started edit command at %s..." (current-time-string))
(message "ticket #%s, %s <- %s" ticket-id field value)
+ (rt-liber-rest-auth)
(let ((request-data
(format "content=%s: %s"
(url-hexify-string field)
- [elpa] externals/rt-liberation 2e9b1f3 01/68: * rt-liberation.el: remove old cli code, (continued)
- [elpa] externals/rt-liberation 2e9b1f3 01/68: * rt-liberation.el: remove old cli code, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation 133559f 18/68: * dir: fix info listing issues take 2, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation 700d45e 21/68: * doc/developer-release.txt: update documentation, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation 4e4cb06 14/68: add manual to ELPA, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation f586e7d 27/68: * doc/rt-liber.texinfo: update manual, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation a5d7634 26/68: * doc/developer-release.txt: add compile comment, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation b2f3f57 02/68: * doc/rt-liberation.texinfo: update documentation, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation 12d16aa 28/68: Add lexical binding declaration, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation ab6c820 33/68: * rt-liberation-viewer.el:, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation ec9245d 37/68: * rt-liberation-viewer.el: start work on formatting, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation 4097a1c 24/68: * rt-liberation-rest.el: new function rt-liber-rest-auth,
Yoni Rabkin <=
- [elpa] externals/rt-liberation 1995685 04/68: * rt-liberation-rest.el: fix undefined variable, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation 0ee9eba 29/68: New file: rt-liberation-viewer, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation 79104c6 42/68: * rt-liberation.el:, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation 73a2ba0 47/68: * rt-liberation.el: find sections, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation 95553c6 51/68: * rt-liberation.el: vernacular time delta, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation fd1e4a9 61/68: * rt-liberation.el: add jump to last section, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation e72ecd8 65/68: * doc/developer-release.txt:, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation 9902111 19/68: * dir: shorten the name of the info file, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation 6098e23 25/68: * rt-liberation-rest.el: add requirement, Yoni Rabkin, 2020/12/16
- [elpa] externals/rt-liberation 7ddbe07 22/68: * NEWS:, Yoni Rabkin, 2020/12/16