Function: auth-source-json-search
auth-source-json-search is a byte-compiled function defined in
auth-source.el.gz.
Signature
(auth-source-json-search &rest SPEC &key BACKEND REQUIRE TYPE MAX HOST USER PORT &allow-other-keys)
Documentation
Given a property list SPEC, return search matches from the :backend.
See auth-source-search for details on SPEC.
Source Code
;; Defined in /usr/src/emacs/lisp/auth-source.el.gz
(cl-defun auth-source-json-search (&rest spec
&key backend require
type max host user port
&allow-other-keys)
"Given a property list SPEC, return search matches from the `:backend'.
See `auth-source-search' for details on SPEC."
;; just in case, check that the type is correct (null or same as the backend)
(cl-assert (or (null type) (eq type (oref backend type)))
t "Invalid JSON search: %s %s")
;; Hide the secrets early to avoid accidental exposure.
(let* ((jdata
(mapcar (lambda (entry)
(let (ret)
(while entry
(let* ((item (pop entry))
(k (auth-source--symbol-keyword (car item)))
(v (cdr item)))
(setq k (cond ((memq k '(:machine)) :host)
((memq k '(:login :account)) :user)
((memq k '(:protocol)) :port)
((memq k '(:password)) :secret)
(t k)))
;; send back the secret in a function (lexical binding)
(when (eq k :secret)
(setq v (let ((lexv v))
(lambda () lexv))))
(setq ret (plist-put ret k v))))
ret))
(json-read-file (oref backend source))))
(max (or max 5000)) ; sanity check: default to stop at 5K
all)
(dolist (item jdata)
(when (and item
(> max (length all))
(auth-source-json-check host user port require item))
(push item all)))
(nreverse all)))