diff options
| author | Teodor Zlatanov | 2011-03-09 13:39:35 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2011-03-09 13:39:35 +0000 |
| commit | 733afdf4d9df952a2d06c40b067de3a62bceb26b (patch) | |
| tree | b097d2a39b6e6a8a9ce80a5f8262a09b36518cc1 /doc/misc | |
| parent | ee545c35d2e83306d50ec78a8d9173ab9011bce5 (diff) | |
| download | emacs-733afdf4d9df952a2d06c40b067de3a62bceb26b.tar.gz emacs-733afdf4d9df952a2d06c40b067de3a62bceb26b.zip | |
Merge changes made in Gnus trunk.
auth-source.el (auth-source-read-char-choice): New function to read a character choice using `dropdown-list', `read-char-choice', or `read-char'. It appends "[a/b/c] " to the prompt if the choices were '(?a ?b ?c). The `dropdown-list' support is disabled for now. Use `eval-when-compile' to load `dropdown-list'.
(auth-source-netrc-saver): Use it.
nnimap.el (nnimap-credentials): Keep the :save-function as the third parameter in the credentials.
(nnimap-open-connection-1): Use it after a successful login.
(nnimap-credentials): Add IMAP-specific user and password prompt.
auth-source.el (auth-source-search): Add :require parameter, taking a list. Document it and the :save-function return token. Pass :require down. Change the CREATED message from a warning to a debug statement.
(auth-source-search-backends): Pass :require down.
(auth-source-netrc-search): Pass :require down.
(auth-source-netrc-parse): Use :require, if it's given, as a filter. Change save prompt to indicate all modifications saved here are deletions.
(auth-source-netrc-create): Take user login name as default in user prompt. Move all the save functionality to a lexically bound function under the :save-function token in the returned list. Set up clearer default prompts for user, host, port, and secret.
(auth-source-netrc-saver): New function, intended to be wrapped for :save-function.
Diffstat (limited to 'doc/misc')
| -rw-r--r-- | doc/misc/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/misc/auth.texi | 64 |
2 files changed, 64 insertions, 5 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index 75674c7fd17..96a2576355a 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-03-08 Teodor Zlatanov <tzz@lifelogs.com> | ||
| 2 | |||
| 3 | * auth.texi (Help for developers): Show example of using | ||
| 4 | `auth-source-search' with prompts and :save-function. | ||
| 5 | |||
| 1 | 2011-03-07 Antoine Levitt <antoine.levitt@gmail.com> | 6 | 2011-03-07 Antoine Levitt <antoine.levitt@gmail.com> |
| 2 | 7 | ||
| 3 | * message.texi (Message Buffers): Update default value of | 8 | * message.texi (Message Buffers): Update default value of |
diff --git a/doc/misc/auth.texi b/doc/misc/auth.texi index 23ac23dce5b..e16d7b49b63 100644 --- a/doc/misc/auth.texi +++ b/doc/misc/auth.texi | |||
| @@ -131,11 +131,11 @@ library encourages this confusion by accepting both, as you'll see | |||
| 131 | later. | 131 | later. |
| 132 | 132 | ||
| 133 | If you have problems with the search, set @code{auth-source-debug} to | 133 | If you have problems with the search, set @code{auth-source-debug} to |
| 134 | @code{t} and see what host, port, and user the library is checking in | 134 | @code{'trivia} and see what host, port, and user the library is |
| 135 | the @code{*Messages*} buffer. Ditto for any other problems, your | 135 | checking in the @code{*Messages*} buffer. Ditto for any other |
| 136 | first step is always to see what's being checked. The second step, of | 136 | problems, your first step is always to see what's being checked. The |
| 137 | course, is to write a blog entry about it and wait for the answer in | 137 | second step, of course, is to write a blog entry about it and wait for |
| 138 | the comments. | 138 | the answer in the comments. |
| 139 | 139 | ||
| 140 | You can customize the variable @code{auth-sources}. The following may | 140 | You can customize the variable @code{auth-sources}. The following may |
| 141 | be needed if you are using an older version of Emacs or if the | 141 | be needed if you are using an older version of Emacs or if the |
| @@ -232,6 +232,14 @@ TODO: how does it work generally, how does secrets.el work, some examples. | |||
| 232 | @node Help for developers | 232 | @node Help for developers |
| 233 | @chapter Help for developers | 233 | @chapter Help for developers |
| 234 | 234 | ||
| 235 | The auth-source library lets you control logging output easily. | ||
| 236 | |||
| 237 | @defvar auth-source-debug | ||
| 238 | Set this variable to 'trivia to see lots of output in *Messages*, or | ||
| 239 | set it to a function that behaves like @code{message} to do your own | ||
| 240 | logging. | ||
| 241 | @end defvar | ||
| 242 | |||
| 235 | The auth-source library only has a few functions for external use. | 243 | The auth-source library only has a few functions for external use. |
| 236 | 244 | ||
| 237 | @defun auth-source-search SPEC | 245 | @defun auth-source-search SPEC |
| @@ -240,6 +248,52 @@ TODO: how to include docstring? | |||
| 240 | 248 | ||
| 241 | @end defun | 249 | @end defun |
| 242 | 250 | ||
| 251 | Let's take a look at an example of using @code{auth-source-search} | ||
| 252 | from Gnus' @code{nnimap.el}. | ||
| 253 | |||
| 254 | @example | ||
| 255 | (defun nnimap-credentials (address ports) | ||
| 256 | (let* ((auth-source-creation-prompts | ||
| 257 | '((user . "IMAP user at %h: ") | ||
| 258 | (secret . "IMAP password for %u@@%h: "))) | ||
| 259 | (found (nth 0 (auth-source-search :max 1 | ||
| 260 | :host address | ||
| 261 | :port ports | ||
| 262 | :require '(:user :secret) | ||
| 263 | :create t)))) | ||
| 264 | (if found | ||
| 265 | (list (plist-get found :user) | ||
| 266 | (let ((secret (plist-get found :secret))) | ||
| 267 | (if (functionp secret) | ||
| 268 | (funcall secret) | ||
| 269 | secret)) | ||
| 270 | (plist-get found :save-function)) | ||
| 271 | nil))) | ||
| 272 | @end example | ||
| 273 | |||
| 274 | This call requires the user and password (secret) to be in the | ||
| 275 | results. It also requests that an entry be created if it doesn't | ||
| 276 | exist already. While the created entry is being assembled, the shown | ||
| 277 | prompts will be used to interact with the user. The caller can also | ||
| 278 | pass data in @code{auth-source-creation-defaults} to supply defaults | ||
| 279 | for any of the prompts. | ||
| 280 | |||
| 281 | Note that the password needs to be evaluated if it's a function. It's | ||
| 282 | wrapped in a function to provide some security. | ||
| 283 | |||
| 284 | Later, after a successful login, @code{nnimal.el} calls the | ||
| 285 | @code{:save-function} like so: | ||
| 286 | |||
| 287 | @example | ||
| 288 | (when (functionp (nth 2 credentials)) | ||
| 289 | (funcall (nth 2 credentials))) | ||
| 290 | @end example | ||
| 291 | |||
| 292 | Which will work whether the @code{:save-function} was provided or not. | ||
| 293 | @code{:save-function} will be provided only when a new entry was | ||
| 294 | created, so this effectively says ``after a successful login, save the | ||
| 295 | authentication information we just used, if it was newly created.'' | ||
| 296 | |||
| 243 | @defun auth-source-delete SPEC | 297 | @defun auth-source-delete SPEC |
| 244 | 298 | ||
| 245 | TODO: how to include docstring? | 299 | TODO: how to include docstring? |