1 ;;; auth-source.el --- authentication sources for Gnus and Emacs
3 ;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
5 ;; Author: Ted Zlatanov <tzz@lifelogs.com>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
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.
30 ;; See the auth.info Info documentation for details.
36 (eval-when-compile (require 'cl))
37 (autoload 'netrc-machine-user-or-password "netrc")
38 (autoload 'secrets-create-item "secrets")
39 (autoload 'secrets-delete-item "secrets")
40 (autoload 'secrets-get-alias "secrets")
41 (autoload 'secrets-get-attribute "secrets")
42 (autoload 'secrets-get-secret "secrets")
43 (autoload 'secrets-list-collections "secrets")
44 (autoload 'secrets-search-items "secrets")
46 (defgroup auth-source nil
47 "Authentication sources."
48 :version "23.1" ;; No Gnus
51 (defcustom auth-source-protocols '((imap "imap" "imaps" "143" "993")
52 (pop3 "pop3" "pop" "pop3s" "110" "995")
56 "List of authentication protocols and their names"
59 :version "23.2" ;; No Gnus
60 :type '(repeat :tag "Authentication Protocols"
61 (cons :tag "Protocol Entry"
62 (symbol :tag "Protocol")
64 (string :tag "Name")))))
66 ;;; generate all the protocols in a format Customize can use
67 ;;; TODO: generate on the fly from auth-source-protocols
68 (defconst auth-source-protocols-customize
70 (let ((p (car-safe a)))
72 :tag (upcase (symbol-name p))
74 auth-source-protocols))
76 (defvar auth-source-cache (make-hash-table :test 'equal)
77 "Cache for auth-source data")
79 (defcustom auth-source-do-cache t
80 "Whether auth-source should cache information."
82 :version "23.2" ;; No Gnus
85 (defcustom auth-source-debug nil
86 "Whether auth-source should log debug messages.
87 Also see `auth-source-hide-passwords'.
89 If the value is nil, debug messages are not logged.
90 If the value is t, debug messages are logged with `message'.
91 In that case, your authentication data will be in the
92 clear (except for passwords, which are always stripped out).
93 If the value is a function, debug messages are logged by calling
94 that function using the same arguments as `message'."
96 :version "23.2" ;; No Gnus
98 :tag "auth-source debugging mode"
99 (const :tag "Log using `message' to the *Messages* buffer" t)
100 (function :tag "Function that takes arguments like `message'")
101 (const :tag "Don't log anything" nil)))
103 (defcustom auth-source-hide-passwords t
104 "Whether auth-source should hide passwords in log messages.
105 Only relevant if `auth-source-debug' is not nil."
107 :version "23.2" ;; No Gnus
110 (defcustom auth-sources '((:source "~/.authinfo.gpg")
111 (:source "~/.authinfo"))
112 "List of authentication sources.
114 The default will get login and password information from a .gpg