Mercurial > emacs
annotate lisp/gnus/auth-source.el @ 111288:6bc575569d37
Silence nnir.el compilation.
* lisp/gnus/nnir.el (declare-function): Add compat stub.
(mm-url-insert, mm-url-encode-www-form-urlencoded): Declare.
(nnir-run-gmane): Require 'mm-url.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sun, 31 Oct 2010 19:38:33 -0700 |
parents | 2a4bfc24abf0 |
children | faa4a1c986c6 |
rev | line source |
---|---|
92694 | 1 ;;; auth-source.el --- authentication sources for Gnus and Emacs |
2 | |
106815 | 3 ;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. |
92694 | 4 |
5 ;; Author: Ted Zlatanov <tzz@lifelogs.com> | |
6 ;; Keywords: news | |
7 | |
8 ;; This file is part of GNU Emacs. | |
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 | 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 | 14 |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
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 | 18 ;; GNU General Public License for more details. |
19 | |
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 | 22 |
23 ;;; Commentary: | |
24 | |
25 ;; This is the auth-source.el package. It lets users tell Gnus how to | |
26 ;; authenticate in a single place. Simplicity is the goal. Instead | |
27 ;; of providing 5000 options, we'll stick to simple, easy to | |
28 ;; understand options. | |
94209 | 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 | 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 | 40 ;;; Code: |
41 | |
94837 | 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 | 44 |
92694 | 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 | 48 (autoload 'secrets-get-alias "secrets") |
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 | 53 |
54 (defgroup auth-source nil | |
55 "Authentication sources." | |
93386 | 56 :version "23.1" ;; No Gnus |
92694 | 57 :group 'gnus) |
58 | |
93386 | 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 | 64 "List of authentication protocols and their names" |
65 | |
66 :group 'auth-source | |
107473 | 67 :version "23.2" ;; No Gnus |
93386 | 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 | 73 |
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 | 76 (defconst auth-source-protocols-customize |
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 | 83 |
99402 | 84 (defvar auth-source-cache (make-hash-table :test 'equal) |
85 "Cache for auth-source data") | |
86 | |
87 (defcustom auth-source-do-cache t | |
88 "Whether auth-source should cache information." | |
89 :group 'auth-source | |
107473 | 90 :version "23.2" ;; No Gnus |
99402 | 91 :type `boolean) |
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 | 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 | 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 | 120 "List of authentication sources. |
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 | 126 Each entry is the authentication type with optional properties. |
127 | |
128 It's best to customize this with `M-x customize-variable' because the choices | |
129 can get pretty complex." | |
92694 | 130 :group 'auth-source |
107473 | 131 :version "23.2" ;; No Gnus |
93386 | 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 | 138 (const :format "" :value :secrets) |
139 (choice :tag "Collection to use" | |
140 (string :tag "Collection name") | |
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 | 161 |
162 ;; temp for debugging | |
93386 | 163 ;; (unintern 'auth-source-protocols) |
164 ;; (unintern 'auth-sources) | |
165 ;; (customize-variable 'auth-sources) | |
166 ;; (setq auth-sources nil) | |
167 ;; (format "%S" auth-sources) | |
168 ;; (customize-variable 'auth-source-protocols) | |
169 ;; (setq auth-source-protocols nil) | |
170 ;; (format "%S" auth-source-protocols) | |
107563
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
171 ;; (auth-source-pick nil :host "a" :port 'imap) |
93386 | 172 ;; (auth-source-user-or-password "login" "imap.myhost.com" 'imap) |
173 ;; (auth-source-user-or-password "password" "imap.myhost.com" 'imap) | |
174 ;; (auth-source-user-or-password-imap "login" "imap.myhost.com") | |
175 ;; (auth-source-user-or-password-imap "password" "imap.myhost.com") | |
176 ;; (auth-source-protocol-defaults 'imap) | |
177 | |
103944
aa77db41a051
Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
101804
diff
changeset
|
178 ;; (let ((auth-source-debug 'debug)) (auth-source-debug "hello")) |
aa77db41a051
Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
101804
diff
changeset
|
179 ;; (let ((auth-source-debug t)) (auth-source-debug "hello")) |
aa77db41a051
Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
101804
diff
changeset
|
180 ;; (let ((auth-source-debug nil)) (auth-source-debug "hello")) |
aa77db41a051
Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
101804
diff
changeset
|
181 (defun auth-source-do-debug (&rest msg) |
aa77db41a051
Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
101804
diff
changeset
|
182 ;; 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
|
183 ;; 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
|
184 ;; we also check the value |
aa77db41a051
Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
101804
diff
changeset
|
185 (when auth-source-debug |
aa77db41a051
Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
101804
diff
changeset
|
186 (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
|
187 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
|
188 'message))) |
103944
aa77db41a051
Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
101804
diff
changeset
|
189 (apply logger msg)))) |
aa77db41a051
Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
101804
diff
changeset
|
190 |
107563
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
191 ;; (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
|
192 ;; (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
|
193 ;; (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
|
194 ;; (: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
|
195 ;; (: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
|
196 ;; (: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
|
197 |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
198 ;; (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
|
199 ;; (: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
|
200 ;; (: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
|
201 ;; )) |
107563
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
202 |
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
203 ;; (setq auth-sources '((:source "~/.authinfo.gpg" :host t :protocol t))) |
93386 | 204 |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
205 (defun auth-get-source (entry) |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
206 "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
|
207 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
|
208 the file name." |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
209 (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
|
210 (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
|
211 source |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
212 ;; Secret Service API. |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
213 (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
|
214 (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
|
215 (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
|
216 (or source "session")))) |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
217 |
107563
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
218 (defun auth-source-pick (&rest spec) |
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
219 "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
|
220 |
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
221 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
|
222 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
|
223 matched as a regex." |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
224 (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
|
225 choices) |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
226 (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
|
227 (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
|
228 (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
|
229 (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
|
230 (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
|
231 ;; 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
|
232 (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
|
233 ;; 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
|
234 (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
|
235 ;; 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
|
236 (file-exists-p source)) |
107563
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
237 |
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
|
238 ;; 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
|
239 (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
|
240 (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
|
241 (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
|
242 (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
|
243 (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
|
244 (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
|
245 (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
|
246 ;; 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
|
247 (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
|
248 ;; 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
|
249 (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
|
250 ;; 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
|
251 (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
|
252 |
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
|
253 (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
|
254 |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
255 (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
|
256 "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
|
257 (catch 'no-password |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
258 (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
|
259 (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
|
260 (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
|
261 (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
|
262 result) |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
263 (cond |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
264 ;; Secret Service API. |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
265 ((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
|
266 (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
|
267 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
|
268 ;; 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
|
269 (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
|
270 (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
|
271 (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
|
272 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
|
273 (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
|
274 (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
|
275 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
|
276 (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
|
277 (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
|
278 ;; 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
|
279 (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
|
280 (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
|
281 (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
|
282 (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
|
283 (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
|
284 ;; 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
|
285 ;; 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
|
286 (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
|
287 (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
|
288 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
|
289 (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
|
290 (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
|
291 ;; Anything else is netrc. |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
292 (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
|
293 (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
|
294 (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
|
295 (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
|
296 (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
|
297 (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
|
298 (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
|
299 '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
|
300 ;; 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
|
301 ;; 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
|
302 (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
|
303 (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
|
304 '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
|
305 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
|
306 (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
|
307 (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
|
308 |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
309 (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
|
310 "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
|
311 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
|
312 (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
|
313 (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
|
314 (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
|
315 (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
|
316 (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
|
317 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
|
318 (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
|
319 result) |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
320 (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
|
321 (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
|
322 (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
|
323 (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
|
324 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
|
325 (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
|
326 ((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
|
327 (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
|
328 (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
|
329 (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
|
330 ;; 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
|
331 ((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
|
332 (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
|
333 '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
|
334 (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
|
335 (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
|
336 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 ((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
|
338 (or user |
110908
2a4bfc24abf0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110799
diff
changeset
|
339 (read-string |
2a4bfc24abf0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110799
diff
changeset
|
340 (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
|
341 (user-login-name)) |
2a4bfc24abf0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110799
diff
changeset
|
342 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
|
343 (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
|
344 "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
|
345 (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
|
346 ;; 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
|
347 (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
|
348 ((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
|
349 ;; 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
|
350 ) |
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
|
351 (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
|
352 ;; 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
|
353 (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
|
354 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
|
355 (netrc-store-data source host 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
|
356 (or user (cdr (assoc "login" 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
|
357 (cdr (assoc "password" 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
|
358 (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
|
359 (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
|
360 (cdar result)))) |
107563
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
361 |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
362 (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
|
363 "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
|
364 (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
|
365 (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
|
366 (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
|
367 (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
|
368 (cond |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
369 ;; Secret Service API. |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
370 ((consp source) |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
371 (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
|
372 ;; 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
|
373 (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
|
374 (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
|
375 (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
|
376 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
|
377 (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
|
378 (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
|
379 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
|
380 (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
|
381 (t)))) ;; netrc not implemented yes. |
93386 | 382 |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
383 (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
|
384 (mode host protocol &optional username) |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
385 "Remove cached authentication token." |
99402 | 386 (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
|
387 (remhash |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
388 (if username |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
389 (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
|
390 (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
|
391 auth-source-cache)) |
99402 | 392 |
101804 | 393 (defun auth-source-forget-all-cached () |
394 "Forget all cached auth-source authentication tokens." | |
395 (interactive) | |
396 (setq auth-source-cache (make-hash-table :test 'equal))) | |
397 | |
107563
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
398 ;; (progn |
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
399 ;; (auth-source-forget-all-cached) |
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
400 ;; (list |
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
401 ;; (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
|
402 ;; (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
|
403 ;; (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
|
404 |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
405 (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
|
406 (mode host protocol &optional username create-missing delete-existing) |
101804 | 407 "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
|
408 |
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
409 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
|
410 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
|
411 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
|
412 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
|
413 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
|
414 |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
415 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
|
416 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
|
417 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
|
418 remove wrong password entries. |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
419 |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
420 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
|
421 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
|
422 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
|
423 `auth-sources'). |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
424 |
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
425 MODE can be \"login\" or \"password\"." |
103944
aa77db41a051
Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
101804
diff
changeset
|
426 (auth-source-do-debug |
107563
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
427 "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
|
428 mode host protocol username) |
101804 | 429 (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
|
430 (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
|
431 (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
|
432 (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
|
433 (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
|
434 (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
|
435 (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
|
436 (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
|
437 (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
|
438 (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
|
439 nil))) |
99402 | 440 (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
|
441 (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
|
442 (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
|
443 "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
|
444 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
|
445 ;; 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
|
446 (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
|
447 "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
|
448 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
|
449 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
|
450 found) ; return the found data |
107563
95c2fdf14356
2010-03-27 Teodor Zlatanov <tzz@lifelogs.com>
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107473
diff
changeset
|
451 ;; else, if not found |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
452 (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
|
453 (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
|
454 (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
|
455 (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
|
456 (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
|
457 (and found (return found))) |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
458 |
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
|
459 ;; 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
|
460 (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
|
461 (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
|
462 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
|
463 (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
|
464 (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
|
465 search))) |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
466 |
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
|
467 ;; 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
|
468 (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
|
469 (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
|
470 "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
|
471 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
|
472 ;; 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
|
473 (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
|
474 "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
|
475 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
|
476 (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
|
477 (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
|
478 (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
|
479 |
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
|
480 found)))) |
108911
a7f706d2c627
* auth-source.el (top): Autoload `secrets-list-collections',
Michael Albinus <michael.albinus@gmx.de>
parents:
107568
diff
changeset
|
481 |
93386 | 482 (defun auth-source-protocol-defaults (protocol) |
483 "Return a list of default ports and names for PROTOCOL." | |
484 (cdr-safe (assoc protocol auth-source-protocols))) | |
485 | |
94369 | 486 (defun auth-source-user-or-password-imap (mode host) |
487 (auth-source-user-or-password mode host 'imap)) | |
93386 | 488 |
94369 | 489 (defun auth-source-user-or-password-pop3 (mode host) |
490 (auth-source-user-or-password mode host 'pop3)) | |
93386 | 491 |
94369 | 492 (defun auth-source-user-or-password-ssh (mode host) |
493 (auth-source-user-or-password mode host 'ssh)) | |
93386 | 494 |
94369 | 495 (defun auth-source-user-or-password-sftp (mode host) |
496 (auth-source-user-or-password mode host 'sftp)) | |
93386 | 497 |
94369 | 498 (defun auth-source-user-or-password-smtp (mode host) |
499 (auth-source-user-or-password mode host 'smtp)) | |
92694 | 500 |
501 (provide 'auth-source) | |
502 | |
503 ;;; auth-source.el ends here |