annotate lisp/gnus/auth-source.el @ 97755:59694c2b2538

emacsclient misbehaves: notabug. http://lists.gnu.org/archive/html/emacs-devel/2008-02/msg00805.html
author Glenn Morris <rgm@gnu.org>
date Wed, 27 Aug 2008 02:40:35 +0000
parents 20496e1c594a
children d0dc678bbb96
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
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
3 ;; Copyright (C) 2008 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
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
30 ;; Easy setup:
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
31 ;; (require 'auth-source)
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
32 ;; (customize-variable 'auth-sources) ;; optional
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
33
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
34 ;; now, whatever sources you've defined for password have to be available
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
35
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
36 ;; if you want encrypted sources, which is strongly recommended, do
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
37 ;; (require 'epa-file)
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
38 ;; (epa-file-mode)
95193
d90ff358ee27 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94980
diff changeset
39 ;; (setq epa-file-cache-passphrase-for-symmetric-encryption t) ; VERY important
94209
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
40
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
41 ;; before you put some data in ~/.authinfo.gpg (the default place)
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
42
94837
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
43 ;;; For url-auth authentication (HTTP/HTTPS), you need to use:
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
44
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
45 ;;; machine yourmachine.com:80 port http login testuser password testpass
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
46
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
47 ;;; This will match any realm and authentication method (basic or
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
48 ;;; digest). If you want finer controls, explore the url-auth source
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
49 ;;; code and variables.
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
50
94980
51e9d65c90fc Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94837
diff changeset
51 ;;; For tramp authentication, use:
51e9d65c90fc Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94837
diff changeset
52
95665
20496e1c594a * auth-source.el: Precise Tramp doc.
Michael Albinus <michael.albinus@gmx.de>
parents: 95193
diff changeset
53 ;;; machine yourmachine.com port scp login testuser password testpass
94980
51e9d65c90fc Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94837
diff changeset
54
95665
20496e1c594a * auth-source.el: Precise Tramp doc.
Michael Albinus <michael.albinus@gmx.de>
parents: 95193
diff changeset
55 ;;; Note that the port denotes the Tramp connection method. When you
20496e1c594a * auth-source.el: Precise Tramp doc.
Michael Albinus <michael.albinus@gmx.de>
parents: 95193
diff changeset
56 ;;; don't use a port entry, you match any Tramp method.
94980
51e9d65c90fc Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94837
diff changeset
57
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
58 ;;; Code:
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
59
94837
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
60 (require 'gnus-util)
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
61
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
62 (eval-when-compile (require 'cl))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
63 (eval-when-compile (require 'netrc))
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
64
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
65 (defgroup auth-source nil
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
66 "Authentication sources."
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
67 :version "23.1" ;; No Gnus
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
68 :group 'gnus)
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
69
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
70 (defcustom auth-source-protocols '((imap "imap" "imaps" "143" "993")
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
71 (pop3 "pop3" "pop" "pop3s" "110" "995")
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
72 (ssh "ssh" "22")
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
73 (sftp "sftp" "115")
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
74 (smtp "smtp" "25"))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
75 "List of authentication protocols and their names"
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
76
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
77 :group 'auth-source
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
78 :version "23.1" ;; No Gnus
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
79 :type '(repeat :tag "Authentication Protocols"
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
80 (cons :tag "Protocol Entry"
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
81 (symbol :tag "Protocol")
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
82 (repeat :tag "Names"
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
83 (string :tag "Name")))))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
84
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
85 ;;; generate all the protocols in a format Customize can use
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
86 (defconst auth-source-protocols-customize
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
87 (mapcar (lambda (a)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
88 (let ((p (car-safe a)))
95665
20496e1c594a * auth-source.el: Precise Tramp doc.
Michael Albinus <michael.albinus@gmx.de>
parents: 95193
diff changeset
89 (list 'const
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
90 :tag (upcase (symbol-name p))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
91 p)))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
92 auth-source-protocols))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
93
94980
51e9d65c90fc Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94837
diff changeset
94 (defcustom auth-sources '((:source "~/.authinfo.gpg" :host t :protocol t))
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
95 "List of authentication sources.
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
96
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
97 Each entry is the authentication type with optional properties."
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
98 :group 'auth-source
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
99 :version "23.1" ;; No Gnus
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
100 :type `(repeat :tag "Authentication Sources"
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
101 (list :tag "Source definition"
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
102 (const :format "" :value :source)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
103 (string :tag "Authentication Source")
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
104 (const :format "" :value :host)
94209
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
105 (choice :tag "Host (machine) choice"
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
106 (const :tag "Any" t)
94209
0ffd6dd0f75d Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 93386
diff changeset
107 (regexp :tag "Host (machine) regular expression (TODO)")
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
108 (const :tag "Fallback" nil))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
109 (const :format "" :value :protocol)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
110 (choice :tag "Protocol"
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
111 (const :tag "Any" t)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
112 (const :tag "Fallback" nil)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
113 ,@auth-source-protocols-customize))))
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
114
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
115 ;; temp for debugging
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
116 ;; (unintern 'auth-source-protocols)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
117 ;; (unintern 'auth-sources)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
118 ;; (customize-variable 'auth-sources)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
119 ;; (setq auth-sources nil)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
120 ;; (format "%S" auth-sources)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
121 ;; (customize-variable 'auth-source-protocols)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
122 ;; (setq auth-source-protocols nil)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
123 ;; (format "%S" auth-source-protocols)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
124 ;; (auth-source-pick "a" 'imap)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
125 ;; (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
126 ;; (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
127 ;; (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
128 ;; (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
129 ;; (auth-source-protocol-defaults 'imap)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
130
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
131 (defun auth-source-pick (host protocol &optional fallback)
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
132 "Parse `auth-sources' for HOST, and PROTOCOL matches.
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
133
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
134 Returns fallback choices (where PROTOCOL or HOST are nil) with FALLBACK t."
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
135 (interactive "sHost: \nsProtocol: \n") ;for testing
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
136 (let (choices)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
137 (dolist (choice auth-sources)
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
138 (let ((h (plist-get choice :host))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
139 (p (plist-get choice :protocol)))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
140 (when (and
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
141 (or (equal t h)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
142 (and (stringp h) (string-match h host))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
143 (and fallback (equal h nil)))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
144 (or (equal t p)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
145 (and (symbolp p) (equal p protocol))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
146 (and fallback (equal p nil))))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
147 (push choice choices))))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
148 (if choices
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
149 choices
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
150 (unless fallback
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
151 (auth-source-pick host protocol t)))))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
152
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
153 (defun auth-source-user-or-password (mode host protocol)
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
154 "Find user or password (from the string MODE) matching HOST and PROTOCOL."
95665
20496e1c594a * auth-source.el: Precise Tramp doc.
Michael Albinus <michael.albinus@gmx.de>
parents: 95193
diff changeset
155 (gnus-message 9
94837
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
156 "auth-source-user-or-password: get %s for %s (%s)"
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
157 mode host protocol)
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
158 (let (found)
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
159 (dolist (choice (auth-source-pick host protocol))
95665
20496e1c594a * auth-source.el: Precise Tramp doc.
Michael Albinus <michael.albinus@gmx.de>
parents: 95193
diff changeset
160 (setq found (netrc-machine-user-or-password
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
161 mode
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
162 (plist-get choice :source)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
163 (list host)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
164 (list (format "%s" protocol))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
165 (auth-source-protocol-defaults protocol)))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
166 (when found
95665
20496e1c594a * auth-source.el: Precise Tramp doc.
Michael Albinus <michael.albinus@gmx.de>
parents: 95193
diff changeset
167 (gnus-message 9
94837
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
168 "auth-source-user-or-password: found %s=%s for %s (%s)"
95665
20496e1c594a * auth-source.el: Precise Tramp doc.
Michael Albinus <michael.albinus@gmx.de>
parents: 95193
diff changeset
169 mode
94837
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
170 ;; don't show the password
95665
20496e1c594a * auth-source.el: Precise Tramp doc.
Michael Albinus <michael.albinus@gmx.de>
parents: 95193
diff changeset
171 (if (equal mode "password") "SECRET" found)
94837
55eb2a3c59b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
172 host protocol)
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
173 (return found)))))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
174
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
175 (defun auth-source-protocol-defaults (protocol)
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
176 "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
177 (cdr-safe (assoc protocol auth-source-protocols)))
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
178
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
179 (defun auth-source-user-or-password-imap (mode host)
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
180 (auth-source-user-or-password mode host 'imap))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
181
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
182 (defun auth-source-user-or-password-pop3 (mode host)
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
183 (auth-source-user-or-password mode host 'pop3))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
184
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
185 (defun auth-source-user-or-password-ssh (mode host)
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
186 (auth-source-user-or-password mode host 'ssh))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
187
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
188 (defun auth-source-user-or-password-sftp (mode host)
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
189 (auth-source-user-or-password mode host 'sftp))
93386
a789a1138b08 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92694
diff changeset
190
94369
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
191 (defun auth-source-user-or-password-smtp (mode host)
86c0a3e7c039 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94209
diff changeset
192 (auth-source-user-or-password mode host 'smtp))
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
193
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
194 (provide 'auth-source)
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
195
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
196 ;; arch-tag: ff1afe78-06e9-42c2-b693-e9f922cbe4ab
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
197 ;;; auth-source.el ends here