~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Patch Queue Manager
  • Date: 2012-07-28 15:55:41 UTC
  • mfrom: (5912.5.9 Base64CredentialStore)
  • Revision ID: pqm@pqm.ubuntu.com-20120728155541-d860rcyc2q82nhnj
(gz) Add Base64CredentialStore for authentication.conf password obfuscation
 (Martin Packman)

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
from bzrlib.decorators import needs_write_lock
82
82
from bzrlib.lazy_import import lazy_import
83
83
lazy_import(globals(), """
 
84
import base64
84
85
import fnmatch
85
86
import re
86
87
 
2131
2132
credential_store_registry.default_key = 'plain'
2132
2133
 
2133
2134
 
 
2135
class Base64CredentialStore(CredentialStore):
 
2136
    __doc__ = """Base64 credential store for the authentication.conf file"""
 
2137
    
 
2138
    def decode_password(self, credentials):
 
2139
        """See CredentialStore.decode_password."""
 
2140
        # GZ 2012-07-28: Will raise binascii.Error if password is not base64,
 
2141
        #                should probably propogate as something more useful.
 
2142
        return base64.decodestring(credentials['password'])
 
2143
 
 
2144
credential_store_registry.register('base64', Base64CredentialStore,
 
2145
                                   help=Base64CredentialStore.__doc__)
 
2146
 
 
2147
 
2134
2148
class BzrDirConfig(object):
2135
2149
 
2136
2150
    def __init__(self, bzrdir):