Function: auth-source-backends-parser-secrets

auth-source-backends-parser-secrets is a byte-compiled function defined in auth-source.el.gz.

Signature

(auth-source-backends-parser-secrets ENTRY)

Source Code

;; Defined in /usr/src/emacs/lisp/auth-source.el.gz
(defun auth-source-backends-parser-secrets (entry)
  ;; take secrets:XYZ and use it as Secrets API collection "XYZ"
  ;; matching any user, host, and protocol
  (when (and (stringp entry) (string-match "^secrets:\\(.+\\)" entry))
    (setq entry `(:source (:secrets ,(match-string 1 entry)))))
  ;; take 'default and use it as a Secrets API default collection
  ;; matching any user, host, and protocol
  (when (eq entry 'default)
    (setq entry '(:source (:secrets default))))
  (cond
   ;; the Secrets API.  We require the package, in order to have a
   ;; defined value for `secrets-enabled'.
   ((and
     (not (null (plist-get entry :source))) ; the source must not be nil
     (listp (plist-get entry :source))      ; and it must be a list
     (not (null (plist-get
                 (plist-get entry :source)
                 :secrets))) ; the source must have :secrets
     (require 'secrets nil t)               ; and we must load the Secrets API
     secrets-enabled)                       ; and that API must be enabled

    ;; the source is either the :secrets key in ENTRY or
    ;; if that's missing or nil, it's "session"
    (let ((source (plist-get (plist-get entry :source) :secrets)))

      ;; if the source is a symbol, we look for the alias named so,
      ;; and if that alias is missing, we use "Login"
      (when (symbolp source)
        (setq source (or (secrets-get-alias (symbol-name source))
                         "Login")))

      (if (featurep 'secrets)
          (auth-source-backend
           :source source
           :type 'secrets
           :search-function #'auth-source-secrets-search
           :create-function #'auth-source-secrets-create)
        (auth-source-do-warn
         "auth-source-backend-parse: no Secrets API, ignoring spec: %S" entry)
        (auth-source-backend
         :source ""
         :type 'ignore))))))