~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to doc/developers/authentication-ring.txt

  • Committer: Martin Pool
  • Date: 2007-10-24 02:33:14 UTC
  • mto: This revision was merged to the branch mainline in revision 2933.
  • Revision ID: mbp@sourcefrog.net-20071024023314-l9mscm8wsb1bvj1f
typo

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
This specification also proposes a way to describe credentials so that several
42
42
remote branches can use the same definition. This is particularily important
43
 
for users handling a lot of passwords and who need to update them on a regular
 
43
for users handling a lot of passwords who need to update them on a regular
44
44
basis.
45
45
 
46
46
Rationale
63
63
 
64
64
Note that ssh servers can be configured to use keys instead of (``user``,
65
65
``password``) and, when used with appropriate agents, provide the same kind of
66
 
comfort this specification aims to provide for all other schemes. Since ssh
67
 
agents provide a safer way to secure the passwords, this specification is
68
 
restricted to providing ``user`` but does not provide ``password`` when used
69
 
for ssh.
 
66
comfort this specification aims to provide for all other schemes. These
 
67
specification do not try to cover these configurations by providing
 
68
pass-phrases, but the mechanisms presented *can* be used to provide users.
70
69
 
71
70
Authentication definitions
72
71
--------------------------
73
72
 
74
 
There are two kinds of authentication used by the various schemes supported by
75
 
bzr:
 
73
There are two kinds of authentication used by the various schemes:
76
74
 
77
75
1. user and password
78
76
 
88
86
really needed is (``user``, ``password``, ``host``, ``path``). The ``realm``
89
87
can be ignored [#ignored_realm]_ as long as it is still presented to the user
90
88
when prompting for the password (unless someone found a way to declare two
91
 
different realms for the same path).
 
89
different realms for the same path). 
92
90
 
93
 
``HTTP proxy`` can be handled as ``HTTP`` (or ``HTTPS``) by explicitly
 
91
``HTTP proxy`` can be handled as ``HTTP`` (or ``HTTPS``) by explicitely
94
92
specifying the appropriate port.
95
93
 
96
94
.. [#ignored_realm] The true purpose of realms is to allow the same credentials
103
101
``password``).
104
102
 
105
103
  * ``scheme``: can be empty (meaning the rest of the definition can be used
106
 
    for any scheme), ``SFTP`` and ``bzr+ssh`` should not be used here, ``ssh``
107
 
    should be used instead since this is the real scheme regarding
108
 
    authentication,
 
104
    for any scheme),
109
105
 
110
106
  * ``host``: can be empty (to act as a default for any host),
111
107
 
112
108
  * ``port`` can be empty (useful when an host provides several servers for the
113
 
    same scheme), only numerical values are allowed, this should be used only
114
 
    when the server uses a port different than the scheme standard port,
115
 
 
116
 
  * ``path``: can be empty (FTP or SFTP will never use it),
117
 
 
118
 
  * ``user``: can be empty (``bzr`` will defaults to python's
119
 
    ``getpass.get_user()`` for FTP, SFTP and ssh),
 
109
    same scheme), only numerical values are allowed,
 
110
 
 
111
  * ``path``: can be empty (FTP or SFTP will never user it),
 
112
 
 
113
  * ``user``: can be empty (and will use the same default as ``bzr``, python's
 
114
    ``getpass.get_user()``),
120
115
 
121
116
  * ``password``: can be empty (for security reasons, a user may use the
122
 
    definitions without storing the passwords but want to be prompted ; or the
123
 
    password will be provided by an external plugin via the
124
 
    ``password_encoding`` mechanism decribed below). Must be left empty for
125
 
    ``ssh``.
 
117
    definitions without storing the passwords but want to be prompted).
126
118
 
127
119
  * ``password_encoding``: can be empty (default is ``plaintext``).
128
120
 
129
121
Also note that an optional ``verify_certificates=no`` field will allow the
130
122
connection to ``HTTPS`` hosts that provides a self certified certificate (the
131
 
default should be to refuse the connection and inform the user). (Not
132
 
implemented yet)
 
123
default should be to refuse the connection and inform the user).
133
124
 
134
125
Multiple definitions can be provided and, for a given URL, bzr will select a
135
126
(``user`` [, ``password``]) based on the following rules :
140
131
 
141
132
 3. ``scheme`` matches even if decorators are used in the requested URL,
142
133
 
143
 
 4. ``host`` matches exactly or act as a domain if it starts with '.'
144
 
    (``project.bzr.sf.net`` will match ``.bzr.sf.net`` but ``projectbzr.sf.net``
145
 
    will not match ``bzr.sf.net``).
 
134
 4. ``host`` matches if included in the requested URL. ``foo.net`` will match a
 
135
    requested ``bzr.foo.net``.
146
136
 
147
137
 5. ``port`` matches if included in the requested URL (exact matches only)
148
138
 
158
148
 
159
149
Encoding passwords in ``base64``, while weak, provides protection against
160
150
accidental reading (if an administrator have to look into the file, he will not
161
 
see the passwords in clear).(Not implemented yet).
 
151
see the passwords in clear).
162
152
 
163
 
This specification intends to ease the authentication providing, not to secure
 
153
This specification intend to ease the authentication providing, not to secure
164
154
it in the best possible way.
165
155
 
166
 
Plugins can provide additional password encodings. The provided
167
 
``netrc_credential_store`` plugin can be used as an example implementation.
168
 
 
169
156
Future versions of this specification may provide additional
170
157
encodings [#password_encoding]_.
171
158
 
172
159
.. [#password_encoding] Additional password encoding methods may be defined
173
160
   that will rely on external means to store the password which, in these
174
 
   cases, will not appear anymore in the definition. It is assumed that
175
 
   additional password encodings will provide a storage outside of the file
176
 
   described here. The ``netrc`` encoding, for example, provides passwords by
177
 
   retrieving them from the ``.netrc`` file.
 
161
   cases, will not appear anymore in the definition but be provided. An
 
162
   encoding named ``netrc`` for example will provide passwords by using the
 
163
   ``.netrc`` file.
178
164
 
179
165
File format
180
166
-----------
192
178
    generally servers. The same authentification definition can even be used
193
179
    for several schemes for servers providing those schemes.
194
180
 
195
 
``~/.bazaar/authentication.conf`` will use the same file format as
 
181
``~/.bazaar/authentication.conf`` will use the same file format than
196
182
``~/.bazaar/bazaar.conf``.
197
183
 
198
 
Each section describes an authentication definition.
 
184
Each section will define an authentication definition.
199
185
 
200
186
The section name is an arbitrary string, only the ``DEFAULT`` value is reserved
201
187
and should appear as the *last* section.
211
197
  * ``port``: the port the server is listening,
212
198
 
213
199
  * ``verify_certificates``: to control certificate verification (useful
214
 
    for self certified hosts). This applies to HTTPS only. Accepted values
 
200
    for self certified hosts). This applies to HTTP[S] only. Accepted values
215
201
    are yes and no, default to yes.
216
202
 
217
203
  * ``path``: the branch location,
226
212
 
227
213
This section could define:
228
214
 
229
 
  * ``user``: default user to be used (if not defined the usual
230
 
    bzr way applies, see below).
 
215
  * ``user``: default user to be used.
231
216
 
232
217
  * ``password_encoding``: default password encoding.
233
218
 
251
236
        bzr branch ftp://foo.net/bzr/branch
252
237
        bzr pull ftp://bzr.foo.net/bzr/product/branch/trunk
253
238
 
254
 
  * all connections are done with the same ``user`` (the remote one for which
255
 
    the default bzr one is not appropriate) and the password is always prompted
256
 
    with some exceptions::
 
239
  * all connections are done with the same ``user`` (the local one) and the
 
240
    password is always prompted with some exceptions::
257
241
 
258
242
        # Pet projects on hobby.net
259
243
        [hobby]
 
244
        scheme=https
260
245
        host=r.hobby.net
 
246
        verify_certificates=no
261
247
        user=jim
262
248
        password=obvious1234
263
 
 
 
249
        
264
250
        # Home server
265
251
        [home]
266
 
        scheme=https
267
252
        host=home.net
268
253
        user=joe
269
254
        password='c2VjcmV0LXBhc3M='
270
255
        password_encoding=base64
271
 
        verify_certificates=no # Still searching a free certificate provider
272
 
 
 
256
        
273
257
        [DEFAULT]
274
 
        # Our local user is barbaz, on all remote sites we're known as foobar
275
258
        user=foobar
276
 
 
277
 
  * an HTTP server and a proxy::
 
259
        
 
260
  * an HTTP server that also acts as a proxy (weird)::
278
261
 
279
262
        # development branches on dev server
280
263
        [dev]
283
266
        path=/dev
284
267
        user=user1
285
268
        password=pass1
286
 
 
 
269
        
287
270
        # toy branches
288
271
        [localhost]
289
272
        scheme=http
291
274
        path=/
292
275
        user=user2
293
276
        password=pass2
294
 
 
295
 
        # proxy
 
277
        
 
278
        # Pesky proxy
296
279
        [proxy]
297
280
        scheme=http
298
 
        host=proxy.company.com
299
 
        port=3128
 
281
        host=dev.company.com
300
282
        user=proxyuser1
301
283
        password=proxypass1
302
 
 
303
 
  * source hosting provider declaring sub-domains for each project::
304
 
 
305
 
        [sfnet domain]
306
 
        # we use sftp, but ssh is the scheme used for authentication
307
 
        scheme=ssh
308
 
        # The leading '.' ensures that 'sf.net' alone doesn't match
309
 
        host=.sf.net
310
 
        user=georges
311
 
        password=ben...son
312
 
 
 
284
        
 
285
Note that the proxy should be specified last because it uses no path. An
 
286
alternative is to specify the port used by the proxy.
313
287
 
314
288
UI Changes
315
289
----------
329
303
3. No ``user`` given in the URL (and no ``password``).
330
304
 
331
305
  Get a user from ``~/.bazaar/authentication.conf`` or prompt for one if none is
332
 
  found. Continue as 2. (Not implemented yet)
 
306
  found. Continue as 2.
333
307
 
334
 
Note: A user will be queried only if the server requires it for ``HTTP`` or
335
 
``HTTPS``, other protocols always require a user.
 
308
Note: A user will be queried only if the server requires it for ``HTTP``, other
 
309
protocols always require a user.
336
310
 
337
311
In any case, if the server refuses the authentication, bzr reports to the user
338
312
and terminates.
341
315
--------------------------
342
316
 
343
317
* bzr should be able to prompt for a ``user`` for a given (``scheme``, ``host``
344
 
  [, ``realm``]). Note that ``realm`` is available only after a first
 
318
  [, ``realm``]). Note that ``realm`` may be available only after a first
345
319
  connection attempt to the server.
346
320
 
347
321
* No assumptions should be made about the clients of this service
361
335
  a password.
362
336
 
363
337
* As this specification proposes a matching between some credentials
364
 
  definitions and real urls, the implementation provides an optional UI
365
 
  feedback about which credential definition is used. Using ``-Dauth`` will
366
 
  output some traces in the ``.bzr.log`` file metionning the sections
367
 
  used. This allows the user to validate his definitions.
 
338
  definitions and real urls, the implementation should provide an optional UI
 
339
  feedback about which credential definition is used. That will allow the user
 
340
  to validate his definitions.
368
341
 
369
342
Questions and Answers
370
343
---------------------
378
351
 
379
352
  * What if a ``.netrc`` file exists ?
380
353
 
381
 
    * It is honored if the definition specifies
382
 
      ``password_encoding=netrc``.
 
354
    * It will be honored if the definition specifies
 
355
      ``password_encoding=netrc`` once the appropriate plugin have been
 
356
      written.
383
357
 
384
358
  * What mode should the authentication file use ?
385
359
 
386
360
    * 600 read/write for owner only by default, if another mode (more
387
361
      permissive) is used, a warning will be issued to inform the users of the
388
 
      potential risks.(Not implemented yet)
 
362
      potential risks.
389
363
 
390
364
  * What about using ``seahorse`` on Ubuntu or ``KeyChain Access`` on Mac OS X ?
391
365
 
396
370
    ?
397
371
 
398
372
    * yes and if the user configure a ssh-agent it will not be queried for
399
 
      pass-phrase every time we want to query the file for a password. But
400
 
      that seems a bit extreme for a first version.(Not implemented yet and
401
 
      may be never)
 
373
      pass-phrase every time we want to query the file for a password. But that
 
374
      seems a bit extreme for a first version.
402
375
 
403
376
  * Why can't bzr update the authentication file when it queried the user for a
404
377
    password ?