annotate lisp/gnus/auth-source.el @ 112393:f7e256e5ea88

gnus-art.el (gnus-article-remove-images, gnus-article-show-images): Widen article buffer.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Fri, 21 Jan 2011 04:16:57 +0000
parents 52100bac91db
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1 ;;; auth-source.el --- authentication sources for Gnus and Emacs
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2
112045
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111986
diff changeset
3 ;; Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
4
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
5 ;; Author: Ted Zlatanov <tzz@lifelogs.com>
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
6 ;; Keywords: news
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
7
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
9
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94369
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94369
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94369
diff changeset
13 ;; (at your option) any later version.
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
14
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94369
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
19
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94369
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
22
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
23 ;;; Commentary:
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
24
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
25 ;; This is the auth-source.el package. It lets users tell Gnus how to
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
26 ;; authenticate in a single place. Simplicity is the goal. Instead
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
27 ;; of providing 5000 options, we'll stick to simple, easy to
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
28 ;; understand options.
94209
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
29
103944
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
30 ;; See the auth.info Info documentation for details.
94980
51e9d65c90fc Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94837
diff changeset
31
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
32 ;; TODO:
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
33
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
34 ;; - never decode the backend file unless it's necessary
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
35 ;; - a more generic way to match backends and search backend contents
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
36 ;; - absorb netrc.el and simplify it
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
37 ;; - protect passwords better
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
38 ;; - allow creating and changing netrc lines (not files) e.g. change a password
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
39
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
40 ;;; Code:
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
41
94837
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
42 (require 'gnus-util)
110586
867180d035b0 auth-source.el (auth-source-create): Query the user for whether to store the credentials.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110585
diff changeset
43 (require 'netrc)
94837
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
44
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
45 (eval-when-compile (require 'cl))
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
46 (autoload 'secrets-create-item "secrets")
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
47 (autoload 'secrets-delete-item "secrets")
107473
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
48 (autoload 'secrets-get-alias "secrets")
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
49 (autoload 'secrets-get-attribute "secrets")
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
50 (autoload 'secrets-get-secret "secrets")
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
51 (autoload 'secrets-list-collections "secrets")
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
52 (autoload 'secrets-search-items "secrets")
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
53
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
54 (defgroup auth-source nil
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
55 "Authentication sources."
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
56 :version "23.1" ;; No Gnus
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
57 :group 'gnus)
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
58
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
59 (defcustom auth-source-protocols '((imap "imap" "imaps" "143" "993")
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
60 (pop3 "pop3" "pop" "pop3s" "110" "995")
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
61 (ssh "ssh" "22")
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
62 (sftp "sftp" "115")
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
63 (smtp "smtp" "25"))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
64 "List of authentication protocols and their names"
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
65
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
66 :group 'auth-source
107473
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
67 :version "23.2" ;; No Gnus
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
68 :type '(repeat :tag "Authentication Protocols"
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
69 (cons :tag "Protocol Entry"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
70 (symbol :tag "Protocol")
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
71 (repeat :tag "Names"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
72 (string :tag "Name")))))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
73
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
74 ;;; generate all the protocols in a format Customize can use
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
75 ;;; TODO: generate on the fly from auth-source-protocols
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
76 (defconst auth-source-protocols-customize
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
77 (mapcar (lambda (a)
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
78 (let ((p (car-safe a)))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
79 (list 'const
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
80 :tag (upcase (symbol-name p))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
81 p)))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
82 auth-source-protocols))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
83
99402
d0dc678bbb96 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95665
diff changeset
84 (defvar auth-source-cache (make-hash-table :test 'equal)
d0dc678bbb96 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95665
diff changeset
85 "Cache for auth-source data")
d0dc678bbb96 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95665
diff changeset
86
d0dc678bbb96 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95665
diff changeset
87 (defcustom auth-source-do-cache t
d0dc678bbb96 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95665
diff changeset
88 "Whether auth-source should cache information."
d0dc678bbb96 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95665
diff changeset
89 :group 'auth-source
107473
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
90 :version "23.2" ;; No Gnus
99402
d0dc678bbb96 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95665
diff changeset
91 :type `boolean)
d0dc678bbb96 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95665
diff changeset
92
103944
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
93 (defcustom auth-source-debug nil
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
94 "Whether auth-source should log debug messages.
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
95 Also see `auth-source-hide-passwords'.
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
96
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
97 If the value is nil, debug messages are not logged.
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
98 If the value is t, debug messages are logged with `message'.
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
99 In that case, your authentication data will be in the
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
100 clear (except for passwords, which are always stripped out).
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
101 If the value is a function, debug messages are logged by calling
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
102 that function using the same arguments as `message'."
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
103 :group 'auth-source
107473
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
104 :version "23.2" ;; No Gnus
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
105 :type `(choice
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
106 :tag "auth-source debugging mode"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
107 (const :tag "Log using `message' to the *Messages* buffer" t)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
108 (function :tag "Function that takes arguments like `message'")
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
109 (const :tag "Don't log anything" nil)))
103944
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
110
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
111 (defcustom auth-source-hide-passwords t
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
112 "Whether auth-source should hide passwords in log messages.
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
113 Only relevant if `auth-source-debug' is not nil."
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
114 :group 'auth-source
107473
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
115 :version "23.2" ;; No Gnus
103944
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
116 :type `boolean)
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
117
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
118 (defcustom auth-sources '((:source "~/.authinfo.gpg")
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
119 (:source "~/.authinfo"))
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
120 "List of authentication sources.
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
121
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
122 The default will get login and password information from a .gpg
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
123 file, which you should set up with the EPA/EPG packages to be
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
124 encrypted. See the auth.info manual for details.
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
125
107473
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
126 Each entry is the authentication type with optional properties.
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
127
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
128 It's best to customize this with `M-x customize-variable' because the choices
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
129 can get pretty complex."
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
130 :group 'auth-source
107473
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
131 :version "23.2" ;; No Gnus
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
132 :type `(repeat :tag "Authentication Sources"
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
133 (list :tag "Source definition"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
134 (const :format "" :value :source)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
135 (choice :tag "Authentication backend choice"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
136 (string :tag "Authentication Source (file)")
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
137 (list :tag "secrets.el (Secret Service API/KWallet/GNOME Keyring)"
107473
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
138 (const :format "" :value :secrets)
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
139 (choice :tag "Collection to use"
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
140 (string :tag "Collection name")
0fe940324254 Synch with Gnus trunk
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107433
diff changeset
141 (const :tag "Default" 'default)
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
142 (const :tag "Login" "login")
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
143 (const :tag "Temporary" "session"))))
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
144 (repeat :tag "Extra Parameters" :inline t
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
145 (choice :tag "Extra parameter"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
146 (list :tag "Host (omit to match as a fallback)"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
147 (const :format "" :value :host)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
148 (choice :tag "Host (machine) choice"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
149 (const :tag "Any" t)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
150 (regexp :tag "Host (machine) regular expression")))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
151 (list :tag "Protocol (omit to match as a fallback)"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
152 (const :format "" :value :protocol)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
153 (choice :tag "Protocol"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
154 (const :tag "Any" t)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
155 ,@auth-source-protocols-customize))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
156 (list :tag "User (omit to match as a fallback)" :inline t
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
157 (const :format "" :value :user)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
158 (choice :tag "Personality or username"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
159 (const :tag "Any" t)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
160 (string :tag "Specific user name"))))))))
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
161
111986
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
162 (defcustom auth-source-gpg-encrypt-to t
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
163 "List of recipient keys that `authinfo.gpg' encrypted to.
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
164 If the value is not a list, symmetric encryption will be used."
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
165 :group 'auth-source
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
166 :version "23.2" ;; No Gnus
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
167 :type '(choice (const :tag "Symmetric encryption" t)
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
168 (repeat :tag "Recipient public keys"
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
169 (string :tag "Recipient public key"))))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
170
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
171 ;; temp for debugging
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
172 ;; (unintern 'auth-source-protocols)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
173 ;; (unintern 'auth-sources)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
174 ;; (customize-variable 'auth-sources)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
175 ;; (setq auth-sources nil)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
176 ;; (format "%S" auth-sources)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
177 ;; (customize-variable 'auth-source-protocols)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
178 ;; (setq auth-source-protocols nil)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
179 ;; (format "%S" auth-source-protocols)
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
180 ;; (auth-source-pick nil :host "a" :port 'imap)
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
181 ;; (auth-source-user-or-password "login" "imap.myhost.com" 'imap)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
182 ;; (auth-source-user-or-password "password" "imap.myhost.com" 'imap)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
183 ;; (auth-source-user-or-password-imap "login" "imap.myhost.com")
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
184 ;; (auth-source-user-or-password-imap "password" "imap.myhost.com")
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
185 ;; (auth-source-protocol-defaults 'imap)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
186
103944
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
187 ;; (let ((auth-source-debug 'debug)) (auth-source-debug "hello"))
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
188 ;; (let ((auth-source-debug t)) (auth-source-debug "hello"))
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
189 ;; (let ((auth-source-debug nil)) (auth-source-debug "hello"))
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
190 (defun auth-source-do-debug (&rest msg)
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
191 ;; set logger to either the function in auth-source-debug or 'message
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
192 ;; note that it will be 'message if auth-source-debug is nil, so
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
193 ;; we also check the value
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
194 (when auth-source-debug
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
195 (let ((logger (if (functionp auth-source-debug)
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
196 auth-source-debug
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
197 'message)))
103944
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
198 (apply logger msg))))
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
199
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
200 ;; (auth-source-pick nil :host "any" :protocol 'imap :user "joe")
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
201 ;; (auth-source-pick t :host "any" :protocol 'imap :user "joe")
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
202 ;; (setq auth-sources '((:source (:secrets default) :host t :protocol t :user "joe")
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
203 ;; (:source (:secrets "session") :host t :protocol t :user "joe")
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
204 ;; (:source (:secrets "login") :host t :protocol t)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
205 ;; (:source "~/.authinfo.gpg" :host t :protocol t)))
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
206
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
207 ;; (setq auth-sources '((:source (:secrets default) :host t :protocol t :user "joe")
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
208 ;; (:source (:secrets "session") :host t :protocol t :user "joe")
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
209 ;; (:source (:secrets "login") :host t :protocol t)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
210 ;; ))
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
211
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
212 ;; (setq auth-sources '((:source "~/.authinfo.gpg" :host t :protocol t)))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
213
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
214 (defun auth-get-source (entry)
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
215 "Return the source string of ENTRY, which is one entry in `auth-sources'.
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
216 If it is a Secret Service API, return the collection name, otherwise
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
217 the file name."
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
218 (let ((source (plist-get entry :source)))
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
219 (if (stringp source)
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
220 source
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
221 ;; Secret Service API.
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
222 (setq source (plist-get source :secrets))
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
223 (when (eq source 'default)
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
224 (setq source (or (secrets-get-alias "default") "login")))
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
225 (or source "session"))))
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
226
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
227 (defun auth-source-pick (&rest spec)
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
228 "Parse `auth-sources' for matches of the SPEC plist.
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
229
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
230 Common keys are :host, :protocol, and :user. A value of t in
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
231 SPEC means to always succeed in the match. A string value is
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
232 matched as a regex."
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
233 (let ((keys (loop for i below (length spec) by 2 collect (nth i spec)))
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
234 choices)
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
235 (dolist (choice (copy-tree auth-sources) choices)
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
236 (let ((source (plist-get choice :source))
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
237 (match t))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
238 (when
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
239 (and
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
240 ;; Check existence of source.
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
241 (if (consp source)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
242 ;; Secret Service API.
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
243 (member (auth-get-source choice) (secrets-list-collections))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
244 ;; authinfo file.
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
245 (file-exists-p source))
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
246
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
247 ;; Check keywords.
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
248 (dolist (k keys match)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
249 (let* ((v (plist-get spec k))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
250 (choicev (if (plist-member choice k)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
251 (plist-get choice k) t)))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
252 (setq match
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
253 (and match
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
254 (or
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
255 ;; source always matches spec key
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
256 (eq t choicev)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
257 ;; source key gives regex to match against spec
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
258 (and (stringp choicev) (string-match choicev v))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
259 ;; source key gives symbol to match against spec
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
260 (and (symbolp choicev) (eq choicev v))))))))
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
261
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
262 (add-to-list 'choices choice 'append))))))
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
263
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
264 (defun auth-source-retrieve (mode entry &rest spec)
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
265 "Retrieve MODE credentials according to SPEC from ENTRY."
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
266 (catch 'no-password
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
267 (let ((host (plist-get spec :host))
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
268 (user (plist-get spec :user))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
269 (prot (plist-get spec :protocol))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
270 (source (plist-get entry :source))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
271 result)
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
272 (cond
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
273 ;; Secret Service API.
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
274 ((consp source)
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
275 (let ((coll (auth-get-source entry))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
276 item)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
277 ;; Loop over candidates with a matching host attribute.
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
278 (dolist (elt (secrets-search-items coll :host host) item)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
279 (when (and (or (not user)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
280 (string-equal
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
281 user (secrets-get-attribute coll elt :user)))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
282 (or (not prot)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
283 (string-equal
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
284 prot (secrets-get-attribute coll elt :protocol))))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
285 (setq item elt)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
286 (return elt)))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
287 ;; Compose result.
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
288 (when item
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
289 (setq result
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
290 (mapcar (lambda (m)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
291 (if (string-equal "password" m)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
292 (or (secrets-get-secret coll item)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
293 ;; When we do not find a password,
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
294 ;; we return nil anyway.
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
295 (throw 'no-password nil))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
296 (or (secrets-get-attribute coll item :user)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
297 user)))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
298 (if (consp mode) mode (list mode)))))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
299 (if (consp mode) result (car result))))
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
300 ;; Anything else is netrc.
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
301 (t
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
302 (let ((search (list source (list host) (list (format "%s" prot))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
303 (auth-source-protocol-defaults prot))))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
304 (setq result
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
305 (mapcar (lambda (m)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
306 (if (string-equal "password" m)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
307 (or (apply
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
308 'netrc-machine-user-or-password m search)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
309 ;; When we do not find a password, we
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
310 ;; return nil anyway.
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
311 (throw 'no-password nil))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
312 (or (apply
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
313 'netrc-machine-user-or-password m search)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
314 user)))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
315 (if (consp mode) mode (list mode)))))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
316 (if (consp mode) result (car result)))))))
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
317
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
318 (defun auth-source-create (mode entry &rest spec)
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
319 "Create interactively credentials according to SPEC in ENTRY.
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
320 Return structure as specified by MODE."
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
321 (let* ((host (plist-get spec :host))
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
322 (user (plist-get spec :user))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
323 (prot (plist-get spec :protocol))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
324 (source (plist-get entry :source))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
325 (name (concat (if user (format "%s@" user))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
326 host
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
327 (if prot (format ":%s" prot))))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
328 result)
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
329 (setq result
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
330 (mapcar
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
331 (lambda (m)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
332 (cons
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
333 m
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
334 (cond
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
335 ((equal "password" m)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
336 (let ((passwd (read-passwd
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
337 (format "Password for %s on %s: " prot host))))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
338 (cond
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
339 ;; Secret Service API.
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
340 ((consp source)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
341 (apply
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
342 'secrets-create-item
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
343 (auth-get-source entry) name passwd spec))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
344 (t)) ;; netrc not implemented yes.
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
345 passwd))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
346 ((equal "login" m)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
347 (or user
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110799
diff changeset
348 (read-string
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110799
diff changeset
349 (format "User name for %s on %s (default %s): " prot host
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110799
diff changeset
350 (user-login-name))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110799
diff changeset
351 nil nil (user-login-name))))
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
352 (t
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
353 "unknownuser"))))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
354 (if (consp mode) mode (list mode))))
110586
867180d035b0 auth-source.el (auth-source-create): Query the user for whether to store the credentials.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110585
diff changeset
355 ;; Allow the source to save the data.
867180d035b0 auth-source.el (auth-source-create): Query the user for whether to store the credentials.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110585
diff changeset
356 (cond
867180d035b0 auth-source.el (auth-source-create): Query the user for whether to store the credentials.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110585
diff changeset
357 ((consp source)
867180d035b0 auth-source.el (auth-source-create): Query the user for whether to store the credentials.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110585
diff changeset
358 ;; Secret Service API -- not implemented.
867180d035b0 auth-source.el (auth-source-create): Query the user for whether to store the credentials.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110585
diff changeset
359 )
867180d035b0 auth-source.el (auth-source-create): Query the user for whether to store the credentials.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110585
diff changeset
360 (t
867180d035b0 auth-source.el (auth-source-create): Query the user for whether to store the credentials.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110585
diff changeset
361 ;; netrc interface.
867180d035b0 auth-source.el (auth-source-create): Query the user for whether to store the credentials.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110585
diff changeset
362 (when (y-or-n-p (format "Do you want to save this password in %s? "
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
363 source))
111986
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
364 ;; the code below is almost same as `netrc-store-data' except
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
365 ;; the `epa-file-encrypt-to' hack (see bug#7487).
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
366 (with-temp-buffer
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
367 (when (file-exists-p source)
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
368 (insert-file-contents source))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
369 (when auth-source-gpg-encrypt-to
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
370 ;; making `epa-file-encrypt-to' local to this buffer lets
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
371 ;; epa-file skip the key selection query (see the
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
372 ;; `local-variable-p' check in `epa-file-write-region').
112045
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111986
diff changeset
373 (unless (local-variable-p 'epa-file-encrypt-to (current-buffer))
111986
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
374 (make-local-variable 'epa-file-encrypt-to))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
375 (if (listp auth-source-gpg-encrypt-to)
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
376 (setq epa-file-encrypt-to auth-source-gpg-encrypt-to)))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
377 (goto-char (point-max))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
378 (unless (bolp)
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
379 (insert "\n"))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
380 (insert (format "machine %s login %s password %s port %s\n"
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
381 host
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
382 (or user (cdr (assoc "login" result)))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
383 (cdr (assoc "password" result))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
384 prot))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
385 (write-region (point-min) (point-max) source nil 'silent)))))
110586
867180d035b0 auth-source.el (auth-source-create): Query the user for whether to store the credentials.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110585
diff changeset
386 (if (consp mode)
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
387 (mapcar #'cdr result)
110586
867180d035b0 auth-source.el (auth-source-create): Query the user for whether to store the credentials.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110585
diff changeset
388 (cdar result))))
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
389
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
390 (defun auth-source-delete (entry &rest spec)
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
391 "Delete credentials according to SPEC in ENTRY."
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
392 (let ((host (plist-get spec :host))
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
393 (user (plist-get spec :user))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
394 (prot (plist-get spec :protocol))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
395 (source (plist-get entry :source)))
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
396 (cond
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
397 ;; Secret Service API.
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
398 ((consp source)
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
399 (let ((coll (auth-get-source entry)))
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
400 ;; Loop over candidates with a matching host attribute.
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
401 (dolist (elt (secrets-search-items coll :host host))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
402 (when (and (or (not user)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
403 (string-equal
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
404 user (secrets-get-attribute coll elt :user)))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
405 (or (not prot)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
406 (string-equal
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
407 prot (secrets-get-attribute coll elt :protocol))))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
408 (secrets-delete-item coll elt)))))
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
409 (t)))) ;; netrc not implemented yes.
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
410
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
411 (defun auth-source-forget-user-or-password
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
412 (mode host protocol &optional username)
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
413 "Remove cached authentication token."
99402
d0dc678bbb96 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95665
diff changeset
414 (interactive "slogin/password: \nsHost: \nsProtocol: \n") ;for testing
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
415 (remhash
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
416 (if username
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
417 (format "%s %s:%s %s" mode host protocol username)
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
418 (format "%s %s:%s" mode host protocol))
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
419 auth-source-cache))
99402
d0dc678bbb96 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95665
diff changeset
420
101804
d775b84fdd71 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 101281
diff changeset
421 (defun auth-source-forget-all-cached ()
d775b84fdd71 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 101281
diff changeset
422 "Forget all cached auth-source authentication tokens."
d775b84fdd71 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 101281
diff changeset
423 (interactive)
d775b84fdd71 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 101281
diff changeset
424 (setq auth-source-cache (make-hash-table :test 'equal)))
d775b84fdd71 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 101281
diff changeset
425
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
426 ;; (progn
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
427 ;; (auth-source-forget-all-cached)
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
428 ;; (list
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
429 ;; (auth-source-user-or-password '("login" "password") "imap.myhost.com" "other")
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
430 ;; (auth-source-user-or-password '("login" "password") "imap.myhost.com" "other" "tzz")
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
431 ;; (auth-source-user-or-password '("login" "password") "imap.myhost.com" "other" "joe")))
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
432
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
433 (defun auth-source-user-or-password
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
434 (mode host protocol &optional username create-missing delete-existing)
101804
d775b84fdd71 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 101281
diff changeset
435 "Find MODE (string or list of strings) matching HOST and PROTOCOL.
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
436
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
437 USERNAME is optional and will be used as \"login\" in a search
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
438 across the Secret Service API (see secrets.el) if the resulting
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
439 items don't have a username. This means that if you search for
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
440 username \"joe\" and it matches an item but the item doesn't have
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
441 a :user attribute, the username \"joe\" will be returned.
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
442
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
443 A non nil DELETE-EXISTING means deleting any matching password
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
444 entry in the respective sources. This is useful only when
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
445 CREATE-MISSING is non nil as well; the intended use case is to
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
446 remove wrong password entries.
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
447
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
448 If no matching entry is found, and CREATE-MISSING is non nil,
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
449 the password will be retrieved interactively, and it will be
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
450 stored in the password database which matches best (see
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
451 `auth-sources').
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
452
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
453 MODE can be \"login\" or \"password\"."
103944
aa77db41a051 Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 101804
diff changeset
454 (auth-source-do-debug
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
455 "auth-source-user-or-password: get %s for %s (%s) + user=%s"
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
456 mode host protocol username)
101804
d775b84fdd71 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 101281
diff changeset
457 (let* ((listy (listp mode))
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
458 (mode (if listy mode (list mode)))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
459 (cname (if username
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
460 (format "%s %s:%s %s" mode host protocol username)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
461 (format "%s %s:%s" mode host protocol)))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
462 (search (list :host host :protocol protocol))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
463 (search (if username (append search (list :user username)) search))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
464 (found (if (not delete-existing)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
465 (gethash cname auth-source-cache)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
466 (remhash cname auth-source-cache)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
467 nil)))
99402
d0dc678bbb96 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95665
diff changeset
468 (if found
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
469 (progn
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
470 (auth-source-do-debug
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
471 "auth-source-user-or-password: cached %s=%s for %s (%s) + %s"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
472 mode
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
473 ;; don't show the password
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
474 (if (and (member "password" mode) auth-source-hide-passwords)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
475 "SECRET"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
476 found)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
477 host protocol username)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
478 found) ; return the found data
107563
95c2fdf14356 2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107473
diff changeset
479 ;; else, if not found
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
480 (let ((choices (apply 'auth-source-pick search)))
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
481 (dolist (choice choices)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
482 (if delete-existing
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
483 (apply 'auth-source-delete choice search)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
484 (setq found (apply 'auth-source-retrieve mode choice search)))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
485 (and found (return found)))
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
486
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
487 ;; We haven't found something, so we will create it interactively.
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
488 (when (and (not found) create-missing)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
489 (setq found (apply 'auth-source-create
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
490 mode (if choices
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
491 (car choices)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
492 (car auth-sources))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
493 search)))
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
494
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
495 ;; Cache the result.
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
496 (when found
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
497 (auth-source-do-debug
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
498 "auth-source-user-or-password: found %s=%s for %s (%s) + %s"
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
499 mode
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
500 ;; don't show the password
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
501 (if (and (member "password" mode) auth-source-hide-passwords)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
502 "SECRET" found)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
503 host protocol username)
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
504 (setq found (if listy found (car-safe found)))
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
505 (when auth-source-do-cache
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
506 (puthash cname found auth-source-cache)))
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
507
110799
d2b45bb936b6 gnus-int.el, gnus-util.el: Gnus hooks for the mark get/set operations.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110586
diff changeset
508 found))))
108911
a7f706d2c627 * auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents: 107568
diff changeset
509
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
510 (defun auth-source-protocol-defaults (protocol)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
511 "Return a list of default ports and names for PROTOCOL."
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
512 (cdr-safe (assoc protocol auth-source-protocols)))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
513
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
514 (defun auth-source-user-or-password-imap (mode host)
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
515 (auth-source-user-or-password mode host 'imap))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
516
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
517 (defun auth-source-user-or-password-pop3 (mode host)
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
518 (auth-source-user-or-password mode host 'pop3))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
519
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
520 (defun auth-source-user-or-password-ssh (mode host)
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
521 (auth-source-user-or-password mode host 'ssh))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
522
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
523 (defun auth-source-user-or-password-sftp (mode host)
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
524 (auth-source-user-or-password mode host 'sftp))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
525
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
526 (defun auth-source-user-or-password-smtp (mode host)
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
527 (auth-source-user-or-password mode host 'smtp))
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
528
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
529 (provide 'auth-source)
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
530
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
531 ;;; auth-source.el ends here