:type t
:custom string
:documentation "The backend user.")
- (protocol :initarg :protocol
- :initform t
- :type t
- :custom string
- :documentation "The backend protocol.")
+ (port :initarg :port
+ :initform t
+ :type t
+ :custom string
+ :documentation "The backend protocol.")
(create-function :initarg :create-function
:initform ignore
:type function
:tag "Regular expression")))
(list
:tag "Protocol"
- (const :format "" :value :protocol)
+ (const :format "" :value :port)
(choice
:tag "Protocol"
(const :tag "Any" t)
msg))
-;; (auth-source-pick nil :host "any" :protocol 'imap :user "joe")
-;; (auth-source-pick t :host "any" :protocol 'imap :user "joe")
-;; (setq auth-sources '((:source (:secrets default) :host t :protocol t :user "joe")
-;; (:source (:secrets "session") :host t :protocol t :user "joe")
-;; (:source (:secrets "Login") :host t :protocol t)
-;; (:source "~/.authinfo.gpg" :host t :protocol t)))
+;; (auth-source-pick nil :host "any" :port 'imap :user "joe")
+;; (auth-source-pick t :host "any" :port 'imap :user "joe")
+;; (setq auth-sources '((:source (:secrets default) :host t :port t :user "joe")
+;; (:source (:secrets "session") :host t :port t :user "joe")
+;; (:source (:secrets "Login") :host t :port t)
+;; (:source "~/.authinfo.gpg" :host t :port t)))
-;; (setq auth-sources '((:source (:secrets default) :host t :protocol t :user "joe")
-;; (:source (:secrets "session") :host t :protocol t :user "joe")
-;; (:source (:secrets "Login") :host t :protocol t)
+;; (setq auth-sources '((:source (:secrets default) :host t :port t :user "joe")
+;; (:source (:secrets "session") :host t :port t :user "joe")
+;; (:source (:secrets "Login") :host t :port t)
;; ))
-;; (setq auth-sources '((:source "~/.authinfo.gpg" :host t :protocol t)))
+;; (setq auth-sources '((:source "~/.authinfo.gpg" :host t :port t)))
;; (auth-source-backend-parse "myfile.gpg")
;; (auth-source-backend-parse 'default)
(defun auth-source-backend-parse-parameters (entry backend)
"Fills in the extra auth-source-backend parameters of ENTRY.
-Using the plist ENTRY, get the :host, :protocol, and :user search
-parameters. Accepts :port as an alias to :protocol."
+Using the plist ENTRY, get the :host, :port, and :user search
+parameters."
(let ((entry (if (stringp entry)
nil
entry))
(oset backend host val))
(when (setq val (plist-get entry :user))
(oset backend user val))
- ;; accept :port as an alias for :protocol
- (when (setq val (or (plist-get entry :protocol) (plist-get entry :port)))
- (oset backend protocol val)))
+ (when (setq val (plist-get entry :port))
+ (oset backend port val)))
backend)
;; (mapcar 'auth-source-backend-parse auth-sources)
(defun* auth-source-search (&rest spec
- &key type max host user protocol secret
+ &key type max host user port secret
create delete
&allow-other-keys)
"Search or modify authentication backends according to SPEC.
Typically the :secret property, if present, contains a password.
-Common search keys are :max, :host, :protocol, and :user. In
+Common search keys are :max, :host, :port, and :user. In
addition, :create specifies how tokens will be or created.
Finally, :type can specify which backend types you want to check.
A new token will be created if no matching tokens were found.
The new token will have only the keys the backend requires. For
the netrc backend, for instance, that's the user, host, and
-protocol keys.
+port keys.
Here's an example:
'netrc', maximum one result.
Create a new entry if you found none. The netrc backend will
- automatically require host, user, and protocol. The host will be
+ automatically require host, user, and port. The host will be
'mine'. We prompt for the user with default 'defaultUser' and
- for the protocol without a default. We will not prompt for A, Q,
+ for the port without a default. We will not prompt for A, Q,
or P. The resulting token will only have keys user, host, and
- protocol.\"
+ port.\"
:create '(A B C) also means to create a token if possible.
or 'twosuch' in backends of type 'netrc', maximum one result.
Create a new entry if you found none. The netrc backend will
- automatically require host, user, and protocol. The host will be
+ automatically require host, user, and port. The host will be
'nonesuch' and Q will be 'qqqq'. We prompt for A with default
- 'default A', for B and protocol with default nil, and for the
+ 'default A', for B and port with default nil, and for the
user with default 'defaultUser'. We will not prompt for Q. The
- resulting token will have keys user, host, protocol, A, B, and Q.
+ resulting token will have keys user, host, port, A, B, and Q.
It will not have P with any value, even though P is used in the
search to find only entries that have P set to 'pppp'.\"
:user (X Y Z) means to match only users X, Y, or Z according to
the match rules above. Defaults to t.
-:protocol (P Q R) means to match only protocols P, Q, or R.
+:port (P Q R) means to match only protocols P, Q, or R.
Defaults to t.
:K (V1 V2 V3) for any other key K will match values V1, V2, or
V3 (note the match rules above).
The return value is a list with at most :max tokens. Each token
-is a plist with keys :backend :host :protocol :user, plus any other
+is a plist with keys :backend :host :port :user, plus any other
keys provided by the backend (notably :secret). But note the
exception for :max 0, which see above.
;;; (auth-source-netrc-parse "~/.authinfo.gpg")
(defun* auth-source-netrc-parse (&rest
spec
- &key file max host user protocol delete
+ &key file max host user port delete
&allow-other-keys)
"Parse FILE and return a list of all entries in the file.
Note that the MAX parameter is used so we can exit the parse early."
host
(or
(aget alist "machine")
- (aget alist "host")))
+ (aget alist "host")
+ t))
(auth-source-search-collection
user
(or
(aget alist "login")
(aget alist "account")
- (aget alist "user")))
+ (aget alist "user")
+ t))
(auth-source-search-collection
- protocol
+ port
(or
(aget alist "port")
- (aget alist "protocol"))))
+ (aget alist "protocol")
+ t)))
(decf max)
(push (nreverse alist) result)
;; to delete a line, we just comment it out
(defun* auth-source-netrc-search (&rest
spec
&key backend create delete
- type max host user protocol
+ 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."
:file (oref backend source)
:host (or host t)
:user (or user t)
- :protocol (or protocol t)))))
+ :port (or port t)))))
;; if we need to create an entry AND none were found to match
(when (and create
(defun* auth-source-netrc-create (&rest spec
&key backend
- secret host user protocol create
+ secret host user port create
&allow-other-keys)
- (let* ((base-required '(host user protocol secret))
+ (let* ((base-required '(host user port secret))
;; we know (because of an assertion in auth-source-search) that the
;; :create parameter is either t or a list (which includes nil)
(create-extra (if (eq t create) nil create))
((and (not given-default) (eq r 'user))
(user-login-name))
;; note we need this empty string
- ((and (not given-default) (eq r 'protocol))
+ ((and (not given-default) (eq r 'port))
"")
(t given-default)))
;; the prompt's default string depends on the data so far
;; the prompt should also show what's entered so far
(user-value (aget valist 'user))
(host-value (aget valist 'host))
- (protocol-value (aget valist 'protocol))
+ (port-value (aget valist 'port))
(info-so-far (concat (if user-value
(format "%s@" user-value)
"[USER?]")
(if host-value
(format "%s" host-value)
"[HOST?]")
- (if protocol-value
+ (if port-value
;; this distinguishes protocol between
- (if (zerop (length protocol-value))
+ (if (zerop (length port-value))
"" ; 'entered as "no default"' vs.
- (format ":%s" protocol-value)) ; given
+ (format ":%s" port-value)) ; given
;; and this is when the protocol is unknown
- "[PROTOCOL?]"))))
+ "[PORT?]"))))
;; now prompt if the search SPEC did not include a required key;
;; take the result and put it in `data' AND store it in `valist'
('user "login")
('host "machine")
('secret "password")
- ('protocol "port")
+ ('port "port") ; redundant but clearer
(t (symbol-name r)))
;; the value will be printed in %S format
data))))))
(defun* auth-source-secrets-search (&rest
spec
&key backend create delete label
- type max host user protocol
+ type max host user port
&allow-other-keys)
"Search the Secrets API; spec is like `auth-source'.
nil
(list k (plist-get spec k))))
search-keys)))
- ;; needed keys (always including host, login, protocol, and secret)
+ ;; needed keys (always including host, login, port, and secret)
(returned-keys (mm-delete-duplicates (append
- '(:host :login :protocol :secret)
+ '(:host :login :port :secret)
search-keys)))
(items (loop for item in (apply 'secrets-search-items coll search-spec)
unless (and (stringp label)
(defun* auth-source-secrets-create (&rest
spec
- &key backend type max host user protocol
+ &key backend type max host user port
&allow-other-keys)
;; TODO
;; (apply 'secrets-create-item (auth-get-source entry) name passwd spec)
'auth-source-forget "Emacs 24.1")
(defun auth-source-user-or-password
- (mode host protocol &optional username create-missing delete-existing)
- "Find MODE (string or list of strings) matching HOST and PROTOCOL.
+ (mode host port &optional username create-missing delete-existing)
+ "Find MODE (string or list of strings) matching HOST and PORT.
DEPRECATED in favor of `auth-source-search'!
MODE can be \"login\" or \"password\"."
(auth-source-do-debug
"auth-source-user-or-password: DEPRECATED get %s for %s (%s) + user=%s"
- mode host protocol username)
+ mode host port username)
(let* ((listy (listp mode))
(mode (if listy mode (list mode)))
(cname (if username
- (format "%s %s:%s %s" mode host protocol username)
- (format "%s %s:%s" mode host protocol)))
- (search (list :host host :protocol protocol))
+ (format "%s %s:%s %s" mode host port username)
+ (format "%s %s:%s" mode host port)))
+ (search (list :host host :port port))
(search (if username (append search (list :user username)) search))
(search (if create-missing
(append search (list :create t))
(if (and (member "password" mode) t)
"SECRET"
found)
- host protocol username)
+ host port username)
found) ; return the found data
;; else, if not found, search with a max of 1
(let ((choice (nth 0 (apply 'auth-source-search