diff options
| author | Gnus developers | 2011-02-13 00:25:29 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2011-02-13 00:25:29 +0000 |
| commit | b8e0f0cd20799c025cf4d353c6b1ee74b3c44aad (patch) | |
| tree | 6c2440a24a4e1d4c7bee75c076b3de3baee560f5 /doc | |
| parent | e730aabed55f3b65020672f1d58afc55fda4eef2 (diff) | |
| download | emacs-b8e0f0cd20799c025cf4d353c6b1ee74b3c44aad.tar.gz emacs-b8e0f0cd20799c025cf4d353c6b1ee74b3c44aad.zip | |
Merge changes made in Gnus trunk.
auth.texi (Overview, Help for users, Help for developers): Update docs.
(Help for users): Talk about spaces.
sieve-manage.el: Autoload `auth-source-search'.
(sieve-sasl-auth): Use it.
nnimap.el: Autoload `auth-source-forget+'.
(nnimap-open-connection-1): Use it if the connection fails.
auth-source.el: Require `password-cache'.
(auth-source-hide-passwords, auth-source-cache): Remove and mark obsolete.
(auth-source-magic): Marker for `password-cache' keys.
(auth-source-do-cache): Update docstring.
(auth-source-search): Use and check cache.
(auth-source-forget-all-cached, auth-source-remember)
(auth-source-recall, auth-source-forget, auth-source-forget+)
(auth-source-specmatchp): Caching support functions.
(auth-source-forget-user-or-password, auth-source-forget-all-cached): Remove and obsolete.
(auth-source-user-or-password): Remove caching to further discourage using it. Always hide passwords.
password-cache.el (password-cache-remove): Accept secrets that are not strings.
mail-source.el: Autoload `auth-source-search'.
(mail-source-keyword-map): Note order matters.
(mail-source-set-1): Get all the mail-source source values and defaults and search auth-source on those if needed. This can all probably be simplified.
nnimap.el: Autoload `auth-source-search'.
(nnimap-credentials): Use it.
(nnimap-open-connection-1): Ask for the virtual server and physical address in one shot.
nntp.el: Autoload `auth-source-search'.
(nntp-send-authinfo): Use it. Note TODO.
auth-source.el (auth-source-secrets-search, auth-source-user-or-password): Use `append' instead of `nconc'.
(auth-source-user-or-password): Build return list better and protect against nil :secret.
auth-source.el (top): Require 'eieio unconditionally. Autoload `secrets-get-attributes' instead of `secrets-get-attribute'.
(auth-source-secrets-search): Limit search when `max' is greater than number of results.
auth-source.el (auth-source-secrets-search): Add examples.
auth-source.el (auth-sources): Allow for simpler defaults for Secrets API with a string "secrets:collection-name" and with 'default.
(auth-source-backend-parse): Parse "secrets:collection-name" and 'default. Recurse on parses instead of repeating code. Use the Secrets API is the source is not nil and 'ignore otherwise. Emit a message when ignoring a source.
(auth-source-search): List ignored search keys at the top level.
(auth-source-netrc-create): Use `case' instead of `cond'.
(auth-source-secrets-search): Created with TODOs.
(auth-source-secrets-create): Created with TODOs.
(auth-source-retrieve, auth-source-create, auth-source-delete)
(auth-source-protocol-defaults, auth-source-user-or-password-imap)
(auth-source-user-or-password-pop3, auth-source-user-or-password-ssh)
(auth-source-user-or-password-sftp)
(auth-source-user-or-password-smtp): Removed.
(auth-source-user-or-password): Deprecated and modified to be a wrapper around `auth-source-search'. Not tested thoroughly.
auth-source.el: Bring in assoc and eioeio libraries.
(secrets-enabled): New variable to track the status of the Secrets API.
(auth-source-backend): New EIOEIO class to represent a backend.
(auth-source-creation-defaults): New variable to set prompt defaults during token creation (see the `auth-source-search' docstring for details).
(auth-sources): Simplify to allow a simple string as a netrc backend spec.
(auth-source-backend-parse): Parse a backend from an `auth-sources' spec.
(auth-source-backend-parse-parameters): Fill in the backend parameters.
(auth-source-search): Main auth-source API entry point.
(auth-source-delete): Wrapper around `auth-source-search' for deletion.
(auth-source-search-collection): Helper function for searching.
(auth-source-netrc-parse, auth-source-netrc-normalize)
(auth-source-netrc-search, auth-source-netrc-create): Netrc backend. Supports search, create, and delete.
(auth-source-secrets-search, auth-source-secrets-create): Secrets API backend stubs.
(auth-source-user-or-password): Call `auth-source-search' but it's not ready yet.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/misc/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/misc/auth.texi | 147 |
2 files changed, 72 insertions, 80 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index 71de76e4d91..0832e02fb2b 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog | |||
| @@ -6,6 +6,11 @@ | |||
| 6 | 6 | ||
| 7 | * url.texi: Remove duplicate @dircategory (Bug#7942). | 7 | * url.texi: Remove duplicate @dircategory (Bug#7942). |
| 8 | 8 | ||
| 9 | 2011-02-11 Teodor Zlatanov <tzz@lifelogs.com> | ||
| 10 | |||
| 11 | * auth.texi (Overview, Help for users, Help for developers): Update docs. | ||
| 12 | (Help for users): Talk about spaces. | ||
| 13 | |||
| 9 | 2011-02-09 Paul Eggert <eggert@cs.ucla.edu> | 14 | 2011-02-09 Paul Eggert <eggert@cs.ucla.edu> |
| 10 | 15 | ||
| 11 | * texinfo.tex: Update to version 2011-02-07.16. | 16 | * texinfo.tex: Update to version 2011-02-07.16. |
diff --git a/doc/misc/auth.texi b/doc/misc/auth.texi index bad37dbe85a..2541dba9873 100644 --- a/doc/misc/auth.texi +++ b/doc/misc/auth.texi | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | @setfilename ../../info/auth | 5 | @setfilename ../../info/auth |
| 6 | @settitle Emacs auth-source Library @value{VERSION} | 6 | @settitle Emacs auth-source Library @value{VERSION} |
| 7 | 7 | ||
| 8 | @set VERSION 0.2 | 8 | @set VERSION 0.3 |
| 9 | 9 | ||
| 10 | @copying | 10 | @copying |
| 11 | This file describes the Emacs auth-source library. | 11 | This file describes the Emacs auth-source library. |
| @@ -78,15 +78,19 @@ It is a way for multiple applications to share a single configuration | |||
| 78 | @chapter Overview | 78 | @chapter Overview |
| 79 | 79 | ||
| 80 | The auth-source library is simply a way for Emacs and Gnus, among | 80 | The auth-source library is simply a way for Emacs and Gnus, among |
| 81 | others, to answer the old burning question ``I have a server name and | 81 | others, to answer the old burning question ``What are my user name and |
| 82 | a port, what are my user name and password?'' | 82 | password?'' |
| 83 | 83 | ||
| 84 | The auth-source library actually supports more than just the user name | 84 | (This is different from the old question about burning ``Where is the |
| 85 | (known as the login) or the password, but only those two are in use | 85 | fire extinguisher, please?''.) |
| 86 | today in Emacs or Gnus. Similarly, the auth-source library supports | 86 | |
| 87 | multiple storage formats, currently either the classic ``netrc'' | 87 | The auth-source library supports more than just the user name or the |
| 88 | format, examples of which you can see later in this document, or the | 88 | password (known as the secret). |
| 89 | Secret Service API. | 89 | |
| 90 | Similarly, the auth-source library supports multiple storage backend, | ||
| 91 | currently either the classic ``netrc'' backend, examples of which you | ||
| 92 | can see later in this document, or the Secret Service API. This is | ||
| 93 | done with EIEIO-based backends and you can write your own if you want. | ||
| 90 | 94 | ||
| 91 | @node Help for users | 95 | @node Help for users |
| 92 | @chapter Help for users | 96 | @chapter Help for users |
| @@ -96,25 +100,41 @@ Secret Service API. | |||
| 96 | machine @var{mymachine} login @var{myloginname} password @var{mypassword} port @var{myport} | 100 | machine @var{mymachine} login @var{myloginname} password @var{mypassword} port @var{myport} |
| 97 | @end example | 101 | @end example |
| 98 | 102 | ||
| 99 | The machine is the server (either a DNS name or an IP address). | 103 | The @code{machine} is the server (either a DNS name or an IP address). |
| 104 | It's known as @var{:host} in @code{auth-source-search} queries. You | ||
| 105 | can also use @code{host}. | ||
| 106 | |||
| 107 | The @code{port} is the connection port or protocol. It's known as | ||
| 108 | @var{:port} in @code{auth-source-search} queries. You can also use | ||
| 109 | @code{protocol}. | ||
| 110 | |||
| 111 | The @code{user} is the user name. It's known as @var{:user} in | ||
| 112 | @code{auth-source-search} queries. You can also use @code{login} and | ||
| 113 | @code{account}. | ||
| 114 | |||
| 115 | Spaces are always OK as far as auth-source is concerned (but other | ||
| 116 | programs may not like them). Just put the data in quotes, escaping | ||
| 117 | quotes as you'd expect with @code{\}. | ||
| 118 | |||
| 119 | All these are optional. You could just say (but we don't recommend | ||
| 120 | it, we're just showing that it's possible) | ||
| 100 | 121 | ||
| 101 | The port is optional. If it's missing, auth-source will assume any | 122 | @example |
| 102 | port is OK. Actually the port is a protocol name or a port number so | 123 | password @var{mypassword} |
| 103 | you can have separate entries for port @var{143} and for protocol | 124 | @end example |
| 104 | @var{imap} if you fancy that. Anyway, you can just omit the port if | ||
| 105 | you don't need it. | ||
| 106 | 125 | ||
| 107 | The login and password are simply your login credentials to the server. | 126 | to use the same password everywhere. Again, @emph{DO NOT DO THIS} or |
| 127 | you will be pwned as the kids say. | ||
| 108 | 128 | ||
| 109 | ``Netrc'' files are usually called @code{.authinfo} or @code{.netrc}; | 129 | ``Netrc'' files are usually called @code{.authinfo} or @code{.netrc}; |
| 110 | nowadays @code{.authinfo} seems to be more popular and the auth-source | 130 | nowadays @code{.authinfo} seems to be more popular and the auth-source |
| 111 | library encourages this confusion by making it the default, as you'll | 131 | library encourages this confusion by making it the default, as you'll |
| 112 | see later. | 132 | see later. |
| 113 | 133 | ||
| 114 | If you have problems with the port, set @code{auth-source-debug} to | 134 | If you have problems with the search, set @code{auth-source-debug} to |
| 115 | @code{t} and see what port the library is checking in the | 135 | @code{t} and see what host, port, and user the library is checking in |
| 116 | @code{*Messages*} buffer. Ditto for any other problems, your first | 136 | the @code{*Messages*} buffer. Ditto for any other problems, your |
| 117 | step is always to see what's being checked. The second step, of | 137 | first step is always to see what's being checked. The second step, of |
| 118 | course, is to write a blog entry about it and wait for the answer in | 138 | course, is to write a blog entry about it and wait for the answer in |
| 119 | the comments. | 139 | the comments. |
| 120 | 140 | ||
| @@ -139,56 +159,36 @@ and simplest configuration is: | |||
| 139 | (setq auth-sources '((:source "~/.authinfo.gpg" :host t :protocol t))) | 159 | (setq auth-sources '((:source "~/.authinfo.gpg" :host t :protocol t))) |
| 140 | ;;; mostly equivalent (see below about fallbacks) but shorter: | 160 | ;;; mostly equivalent (see below about fallbacks) but shorter: |
| 141 | (setq auth-sources '((:source "~/.authinfo.gpg"))) | 161 | (setq auth-sources '((:source "~/.authinfo.gpg"))) |
| 162 | ;;; even shorter and the @emph{default}: | ||
| 163 | (setq auth-sources '("~/.authinfo.gpg" "~/.authinfo")) | ||
| 164 | ;;; use the Secrets API @var{login} collection (@pxref{Secret Service API}) | ||
| 165 | (setq auth-sources '("secrets:login")) | ||
| 142 | @end lisp | 166 | @end lisp |
| 143 | 167 | ||
| 144 | This says ``for any host and any protocol, use just that one file.'' | ||
| 145 | Sweet simplicity. In fact, the latter is already the default, so | ||
| 146 | unless you want to move your netrc file, it will just work if you have | ||
| 147 | that file. Make sure it exists. | ||
| 148 | |||
| 149 | By adding multiple entries to @code{auth-sources} with a particular | 168 | By adding multiple entries to @code{auth-sources} with a particular |
| 150 | host or protocol, you can have specific netrc files for that host or | 169 | host or protocol, you can have specific netrc files for that host or |
| 151 | protocol. Usually this is unnecessary but may make sense if you have | 170 | protocol. Usually this is unnecessary but may make sense if you have |
| 152 | shared netrc files or some other unusual setup (90% of Emacs users | 171 | shared netrc files or some other unusual setup (90% of Emacs users |
| 153 | have unusual setups and the remaining 10% are @emph{really} unusual). | 172 | have unusual setups and the remaining 10% are @emph{really} unusual). |
| 154 | 173 | ||
| 155 | Here's an example that uses the Secret Service API for all lookups, | 174 | Here's a mixed example using two sources: |
| 156 | using the default collection: | ||
| 157 | |||
| 158 | @lisp | ||
| 159 | (setq auth-sources '((:source (:secrets default)))) | ||
| 160 | @end lisp | ||
| 161 | |||
| 162 | And here's a mixed example, using two sources: | ||
| 163 | 175 | ||
| 164 | @lisp | 176 | @lisp |
| 165 | (setq auth-sources '((:source (:secrets default) :host "myserver" :user "joe") | 177 | (setq auth-sources '((:source (:secrets default) :host "myserver" :user "joe") |
| 166 | (:source "~/.authinfo.gpg"))) | 178 | "~/.authinfo.gpg")) |
| 167 | @end lisp | 179 | @end lisp |
| 168 | 180 | ||
| 169 | The best match is determined by order (starts from the bottom) only | ||
| 170 | for the first pass, where things are checked exactly. In the example | ||
| 171 | above, the first pass would find a single match for host | ||
| 172 | @code{myserver}. The netrc choice would fail because it matches any | ||
| 173 | host and protocol implicitly (as a @emph{fallback}). A specified | ||
| 174 | value of @code{:host t} in @code{auth-sources} is considered a match | ||
| 175 | on the first pass, unlike a missing @code{:host}. | ||
| 176 | |||
| 177 | Now if you look for host @code{missing}, it won't match either source | ||
| 178 | explicitly. The second pass (the @emph{fallback} pass) will look at | ||
| 179 | all the implicit matches and collect them. They will be scored and | ||
| 180 | returned sorted by score. The score is based on the number of | ||
| 181 | explicit parameters that matched. See the @code{auth-pick} function | ||
| 182 | for details. | ||
| 183 | |||
| 184 | @end defvar | 181 | @end defvar |
| 185 | 182 | ||
| 186 | If you don't customize @code{auth-sources}, you'll have to live with | 183 | If you don't customize @code{auth-sources}, you'll have to live with |
| 187 | the defaults: any host and any port are looked up in the netrc | 184 | the defaults: any host and any port are looked up in the netrc |
| 188 | file @code{~/.authinfo.gpg}, which is a GnuPG encrypted file | 185 | file @code{~/.authinfo.gpg}, which is a GnuPG encrypted file |
| 189 | (@pxref{GnuPG and EasyPG Assistant Configuration}). | 186 | (@pxref{GnuPG and EasyPG Assistant Configuration}). |
| 187 | |||
| 188 | If that fails, the unencrypted netrc file @code{~/.authinfo} will | ||
| 189 | be used. | ||
| 190 | 190 | ||
| 191 | The simplest working netrc line example is one without a port. | 191 | The typical netrc line example is without a port. |
| 192 | 192 | ||
| 193 | @example | 193 | @example |
| 194 | machine YOURMACHINE login YOU password YOURPASSWORD | 194 | machine YOURMACHINE login YOU password YOURPASSWORD |
| @@ -233,42 +233,29 @@ TODO: how does it work generally, how does secrets.el work, some examples. | |||
| 233 | @node Help for developers | 233 | @node Help for developers |
| 234 | @chapter Help for developers | 234 | @chapter Help for developers |
| 235 | 235 | ||
| 236 | The auth-source library only has one function for external use. | 236 | The auth-source library only has a few functions for external use. |
| 237 | 237 | ||
| 238 | @defun auth-source-user-or-password mode host port &optional username | 238 | @defun auth-source-search SPEC |
| 239 | 239 | ||
| 240 | Retrieve appropriate authentication tokens, determined by @var{mode}, | 240 | TODO: how to include docstring? |
| 241 | for host @var{host} and @var{port}. If @var{username} is provided it | ||
| 242 | will also be checked. If @code{auth-source-debug} is t, debugging | ||
| 243 | messages will be printed. Set @code{auth-source-debug} to a function | ||
| 244 | to use that function for logging. The parameters passed will be the | ||
| 245 | same that the @code{message} function takes, that is, a string | ||
| 246 | formatting spec and optional parameters. | ||
| 247 | 241 | ||
| 248 | If @var{mode} is a list of strings, the function will return a list of | 242 | @end defun |
| 249 | strings or @code{nil} objects (thus you can avoid parsing the netrc | ||
| 250 | file or checking the Secret Service API more than once). If it's a | ||
| 251 | string, the function will return a string or a @code{nil} object. | ||
| 252 | Currently only the modes ``login'' and ``password'' are recognized but | ||
| 253 | more may be added in the future. | ||
| 254 | 243 | ||
| 255 | @var{host} is a string containing the host name. | 244 | @defun auth-source-delete SPEC |
| 256 | 245 | ||
| 257 | @var{port} contains the protocol name (e.g. ``imap'') or | 246 | TODO: how to include docstring? |
| 258 | a port number. It must be a string, corresponding to the port in the | ||
| 259 | users' netrc files. | ||
| 260 | 247 | ||
| 261 | @var{username} contains the user name (e.g. ``joe'') as a string. | 248 | @end defun |
| 262 | 249 | ||
| 263 | @example | 250 | @defun auth-source-forget SPEC |
| 264 | ;; IMAP example | 251 | |
| 265 | (setq auth (auth-source-user-or-password | 252 | TODO: how to include docstring? |
| 266 | '("login" "password") | 253 | |
| 267 | "anyhostnamehere" | 254 | @end defun |
| 268 | "imap")) | 255 | |
| 269 | (nth 0 auth) ; the login name | 256 | @defun auth-source-forget+ SPEC |
| 270 | (nth 1 auth) ; the password | 257 | |
| 271 | @end example | 258 | TODO: how to include docstring? |
| 272 | 259 | ||
| 273 | @end defun | 260 | @end defun |
| 274 | 261 | ||