~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/_urllib2_wrappers.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-12-29 14:29:16 UTC
  • mfrom: (3920.1.1 bzr.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20081229142916-z08eu2alga2acrh6
(vila) Fix bug #300347 by allowing authentication.conf to be used
        even if no user appears in HTTP[S] urls

Show diffs side-by-side

added added

removed removed

Lines of Context:
965
965
            raise KeyError('%s not found' % self.auth_required_header)
966
966
 
967
967
        auth = self.get_auth(request)
968
 
        if auth.get('user', None) is None:
969
 
            # Without a known user, we can't authenticate
970
 
            return None
971
 
 
972
968
        auth['modified'] = False
973
969
        if self.auth_match(server_header, auth):
974
970
            # auth_match may have modified auth (by adding the
978
974
                # We already tried that, give up
979
975
                return None
980
976
 
 
977
            if auth.get('user', None) is None:
 
978
                # Without a known user, we can't authenticate
 
979
                return None
 
980
 
981
981
            # Housekeeping
982
982
            request.connection.cleanup_pipe()
983
983
            response = self.parent.open(request)
1039
1039
        self._retry_count = None
1040
1040
 
1041
1041
    def get_user_password(self, auth):
1042
 
        """Ask user for a password if none is already available."""
 
1042
        """Ask user for a password if none is already available.
 
1043
 
 
1044
        :param auth: authentication info gathered so far (from the initial url
 
1045
            and then during dialog with the server).
 
1046
        """
1043
1047
        auth_conf = config.AuthenticationConfig()
1044
1048
        user = auth['user']
1045
1049
        password = auth['password']
1046
1050
        realm = auth['realm']
1047
1051
 
1048
1052
        if user is None:
1049
 
            user = auth.get_user(auth['protocol'], auth['host'],
1050
 
                                 port=auth['port'], path=auth['path'],
1051
 
                                 realm=realm)
1052
 
            if user is None:
1053
 
                # Default to local user
1054
 
                user = getpass.getuser()
1055
 
 
1056
 
        if password is None:
 
1053
            user = auth_conf.get_user(auth['protocol'], auth['host'],
 
1054
                                      port=auth['port'], path=auth['path'],
 
1055
                                      realm=realm)
 
1056
        if user is not None and password is None:
1057
1057
            password = auth_conf.get_password(
1058
1058
                auth['protocol'], auth['host'], user, port=auth['port'],
1059
1059
                path=auth['path'], realm=realm,