Merge lp:~florian-dorn/bzr/Base64CredentialStore into lp:bzr

Proposed by Florian Dorn
Status: Superseded
Proposed branch: lp:~florian-dorn/bzr/Base64CredentialStore
Merge into: lp:bzr
Diff against target: 67 lines (+20/-1)
3 files modified
bzrlib/config.py (+10/-0)
bzrlib/tests/test_config.py (+8/-0)
doc/developers/authentication-ring.txt (+2/-1)
To merge this branch: bzr merge lp:~florian-dorn/bzr/Base64CredentialStore
Reviewer Review Type Date Requested Status
Vincent Ladeuil Needs Information
Martin Pool Needs Fixing
Review via email: mp+63473@code.launchpad.net

This proposal has been superseded by a proposal from 2012-04-03.

Description of the change

Implements a base64 credential store (fixes bug #788015), for obfruscating passwords in authentication.conf

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

Hi, Florian, thanks for this contribution.

Could you please complete <http://www.canonical.com/contributors>?

[question] I wonder how people will discover they can use this. It seems to me we ought to update at least the developer docs that say this is not implemented; add it to news and whatsnew; also perhaps add it into the user guide about authentication. Perhaps this should even become the default?

+ __doc__ = """Base64 credential store for the authentication.conf file"""

[fix] A literal string occurring as the first thing in a class or other block is automatically the docstring in Python.

[tweak] Could you please mention here that the point of this class is to obfuscate the passwords stored in the file?

[fix] This ought to be tested; there is a test_decode_password and TestPlainTextCredentialStore in tests/test_config.py. If you're having trouble adding one just ask and we will help or do it.

I wonder how people are going to discover that this exists? I think

review: Needs Fixing
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 6/6/2011 4:46 AM, Martin Pool wrote:
> Review: Needs Fixing
> Hi, Florian, thanks for this contribution.
>
> Could you please complete <http://www.canonical.com/contributors>?
>
> [question] I wonder how people will discover they can use this. It seems to me we ought to update at least the developer docs that say this is not implemented; add it to news and whatsnew; also perhaps add it into the user guide about authentication. Perhaps this should even become the default?
>
> + __doc__ = """Base64 credential store for the authentication.conf file"""

>
> [fix] A literal string occurring as the first thing in a class or other block is automatically the docstring in Python.

We use "__doc__" for Command classes because -OO doesn't strip it out.
We might be using it similarly here. If a doc string ends up in 'bzr
help' text, we want to use __doc__ = ...

>
> [tweak] Could you please mention here that the point of this class is to obfuscate the passwords stored in the file?
>
> [fix] This ought to be tested; there is a test_decode_password and TestPlainTextCredentialStore in tests/test_config.py. If you're having trouble adding one just ask and we will help or do it.
>
> I wonder how people are going to discover that this exists? I think

Would it show up under "bzr help authentication"? If not, it probably
should.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3s43YACgkQJdeBCYSNAAOKHACeN0ZHUveykAFo9dckb8e0tkMm
RP4AoNiJSYE7DR8dJx1zD+1QB+pGkKjb
=D6By
-----END PGP SIGNATURE-----

Revision history for this message
Vincent Ladeuil (vila) wrote :

@Florian: Do you need help here ?

How do you use this store ? You put your encoded credentials into authentication.conf manually ?

review: Needs Information
Revision history for this message
Florian Dorn (florian-dorn) wrote :

@Vincent:
the base64 encoded password can be generated with:
echo -n "secret" | base64
and put there manually

Revision history for this message
Martin Pool (mbp) wrote :

On 7 June 2011 00:25, John Arbash Meinel <email address hidden> wrote:

>> [question] I wonder how people will discover they can use this.  It seems to me we ought to update at least the developer docs that say this is not implemented; add it to news and whatsnew; also perhaps add it into the user guide about authentication.  Perhaps this should even become the default?
>>
>> +    __doc__ = """Base64 credential store for the authentication.conf file"""
>
>
>>
>> [fix] A literal string occurring as the first thing in a class or other block is automatically the docstring in Python.
>
> We use "__doc__" for Command classes because -OO doesn't strip it out.
> We might be using it similarly here. If a doc string ends up in 'bzr
> help' text, we want to use __doc__ = ...

[aside] Right, but if this is going to be user documentation it ought
to be written in a different way, describing how to use it, not what
the class is. The parent AuthenticationConfig doesn't declare an
explicity __doc__. Perhaps we should move away from that to say
instead help="""..."""

[fix] At the moment there is "bzr help authentication" apparently
taken from a static file, and that ought to be updated to explain how
to use it.

Revision history for this message
Vincent Ladeuil (vila) wrote :

> @Vincent:
> the base64 encoded password can be generated with:
> echo -n "secret" | base64
> and put there manually

Great, that's worth adding to the doc (you need to specify password_encoding=base64 too right ?).

I'll put the proposal in the 'Work In Progress' state. When you want it to be reviewed again, just push your new changes to lp and put the proposal back to the 'Needs Review' state.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/config.py'
2--- bzrlib/config.py 2012-03-29 12:27:52 +0000
3+++ bzrlib/config.py 2012-04-03 15:08:28 +0000
4@@ -76,6 +76,7 @@
5 from cStringIO import StringIO
6 import os
7 import sys
8+import base64
9
10 import bzrlib
11 from bzrlib.decorators import needs_write_lock
12@@ -2130,6 +2131,15 @@
13 help=PlainTextCredentialStore.__doc__)
14 credential_store_registry.default_key = 'plain'
15
16+class Base64CredentialStore(CredentialStore):
17+ __doc__ = """Base64 credential store for the authentication.conf file"""
18+
19+ def decode_password(self, credentials):
20+ """See CredentialStore.decode_password."""
21+ return base64.decodestring(credentials['password'])
22+
23+credential_store_registry.register('base64', Base64CredentialStore,
24+ help=Base64CredentialStore.__doc__)
25
26 class BzrDirConfig(object):
27
28
29=== modified file 'bzrlib/tests/test_config.py'
30--- bzrlib/tests/test_config.py 2012-03-29 12:27:52 +0000
31+++ bzrlib/tests/test_config.py 2012-04-03 15:08:28 +0000
32@@ -4815,6 +4815,14 @@
33 decoded = plain_text.decode_password(dict(password='secret'))
34 self.assertEquals('secret', decoded)
35
36+class TestBase64CredentialStore(tests.TestCase):
37+
38+ def test_decode_password(self):
39+ import base64
40+ r = config.credential_store_registry
41+ plain_text = r.get_credential_store('base64')
42+ decoded = plain_text.decode_password(dict(password=base64.encodestring('secret-pass')))
43+ self.assertEquals('secret-pass', decoded)
44
45 # FIXME: Once we have a way to declare authentication to all test servers, we
46 # can implement generic tests.
47
48=== modified file 'doc/developers/authentication-ring.txt'
49--- doc/developers/authentication-ring.txt 2010-11-12 22:46:28 +0000
50+++ doc/developers/authentication-ring.txt 2012-04-03 15:08:28 +0000
51@@ -158,7 +158,7 @@
52
53 Encoding passwords in ``base64``, while weak, provides protection against
54 accidental reading (if an administrator have to look into the file, he will not
55-see the passwords in clear).(Not implemented yet).
56+see the passwords in clear).
57
58 This specification intends to ease the authentication providing, not to secure
59 it in the best possible way.
60@@ -266,6 +266,7 @@
61 scheme=https
62 host=home.net
63 user=joe
64+ # Obtain the base64 encoded password by running 'echo -n "secret-pass" | base64'
65 password='c2VjcmV0LXBhc3M='
66 password_encoding=base64
67 verify_certificates=no # Still searching a free certificate provider