Merge from emacs--devo--0
[gnus] / texi / auth.texi
1 \input texinfo                  @c -*-texinfo-*-
2
3 @setfilename auth.info
4 @settitle Emacs auth-source Library @value{VERSION}
5
6 @set VERSION 0.1
7
8 @dircategory Emacs
9 @direntry
10 * auth-source: (auth).   The Emacs auth-source library.
11 @end direntry
12
13 @settitle Emacs auth-source Library @value{VERSION}
14
15 @copying
16 This file describes the Emacs auth-source library.
17
18 Copyright @copyright{} 2008, 2009
19 Free Software Foundation, Inc.
20
21 @quotation
22 Permission is granted to copy, distribute and/or modify this document
23 under the terms of the GNU Free Documentation License, Version 1.3 or
24 any later version published by the Free Software Foundation; with no
25 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
26 and with the Back-Cover Texts as in (a) below.  A copy of the license
27 is included in the section entitled ``GNU Free Documentation License''
28 in the Emacs manual.
29
30 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
31 modify this GNU manual.  Buying copies from the FSF supports it in
32 developing GNU and promoting software freedom.''
33
34 This document is part of a collection distributed under the GNU Free
35 Documentation License.  If you want to distribute this document
36 separately from the collection, you can do so by adding a copy of the
37 license to the document, as described in section 6 of the license.
38 @end quotation
39 @end copying
40
41 @dircategory Emacs
42 @direntry
43 * Auth-source: (auth).   The Emacs auth-source library.
44 @end direntry
45
46 @titlepage
47 @title Emacs auth-source Library
48
49 @author by Ted Zlatanov
50 @page
51
52 @vskip 0pt plus 1filll
53 @insertcopying
54 @end titlepage
55 @page
56
57 @end tex
58
59 @node Top
60 @top Emacs auth-source
61 This manual describes the Emacs auth-source library.
62
63 It is a way for multiple applications to share a single configuration
64 (in Emacs and in files) for user convenience.
65
66 @menu
67 * Overview::                    Overview of the auth-source library.
68 * Help for users::              
69 * Help for developers::         
70 * Index::                       
71 * Function Index::              
72 * Variable Index::              
73 @end menu
74
75 @node Overview
76 @chapter Overview
77
78 To be done.
79
80 @node Help for users
81 @chapter Help for users
82
83 If you have problems with the port, turn up @code{gnus-verbose} and
84 see what port the library is checking.  Ditto for any other
85 problems, your first step is to see what's being checked.
86
87 Setup:
88
89 @lisp
90 (require 'auth-source)
91 (customize-variable 'auth-sources) ;; optional, do it once
92 @end lisp
93
94 @defvar auth-sources
95
96 The @var{auth-sources} variable tells the auth-source library where
97 your netrc files live for a particular host and protocol.  While you
98 can get fancy, the default and simplest configuration is:
99
100 @lisp
101 (setq auth-sources '((:source "~/.authinfo.gpg" :host t :protocol t)))
102 @end lisp
103
104 By adding multiple entries to that list with a particular host or
105 protocol, you can have specific netrc files for that host or protocol.
106
107 @end defvar
108
109
110 ``Netrc'' files are a de facto standard.  They look like this:
111 @example
112 machine mymachine login myloginname password mypassword port myport
113 @end example
114
115 The port is optional.  If it's missing, auth-source will assume any
116 port is OK.  Actually the port is a protocol name or a port number so
117 you can have separate entries for port 143 and for protocol ``imap''
118 if you fancy that.
119
120 If you don't customize @var{auth-sources}, you'll have to live with
121 the defaults: any host and any port are looked up in the netrc
122 file @code{~/.authinfo.gpg}.  This is an encrypted file if and only if
123 you set up EPA, which is strongly recommended.
124
125 @lisp
126 (require 'epa-file)
127 (epa-file-enable)
128 (setq epa-file-cache-passphrase-for-symmetric-encryption t) ; VERY important
129 @end lisp
130
131 For url-auth authentication (HTTP/HTTPS), you need to put this in your
132 netrc file:
133
134 @example
135 machine yourmachine.com:80 port http login testuser password testpass
136 @end example
137
138 This will match any realm and authentication method (basic or
139 digest).  If you want finer controls, explore the url-auth source
140 code and variables.
141
142 For Tramp authentication, use:
143
144 @example
145 machine yourmachine.com port scp login testuser password testpass
146 @end example
147
148 Note that the port denotes the Tramp connection method.  When you
149 don't use a port entry, you match any Tramp method, as explained
150 earlier.
151
152 @node Help for developers
153 @chapter Help for developers
154
155 The auth-source library only has one function for external use.
156
157 @defun auth-source-user-or-password mode host port
158
159 Retrieve appropriate authentication tokens, determined by @var{mode},
160 for host @var{host} and @var{port}.  If @code{gnus-verbose} is 9 or
161 higher, debugging messages will be printed.
162
163 If @var{mode} is a list of strings, the function will return a list of
164 strings or @code{nil} objects.  If it's a string, the function will
165 return a string or a @code{nil} object.  Currently only the modes
166 ``login'' and ``password'' are recognized but more may be added in the
167 future.
168
169 @var{host} is a string containing the host name.
170
171 @var{port} contains the protocol name (e.g. ``imap'') or
172 a port number.  It must be a string, corresponding to the port in the
173 users' netrc files.
174
175 @example
176 ;; IMAP example
177 (setq auth (auth-source-user-or-password
178             '("login" "password")
179             "anyhostnamehere"
180             "imap"))
181 (nth 0 auth) ; the login name
182 (nth 1 auth) ; the password
183 @end example
184
185 @end defun
186
187 @node Index
188 @chapter Index
189 @printindex cp
190
191 @node Function Index
192 @chapter Function Index
193 @printindex fn
194
195 @node Variable Index
196 @chapter Variable Index
197 @printindex vr
198
199 @summarycontents
200 @contents
201 @bye
202
203 @c End:
204
205 @ignore
206    arch-tag: 7b835fd3-473f-40fc-9776-1c4e49d26c94
207 @end ignore