Rev 2920: http can query AuthenticationConfig for logins too. in http://code.launchpad.net/%7Ev-ladeuil/bzr/auth.ring
Vincent Ladeuil
v.ladeuil+lp at free.fr
Tue Oct 23 11:58:23 BST 2007
At http://code.launchpad.net/%7Ev-ladeuil/bzr/auth.ring
------------------------------------------------------------
revno: 2920
revision-id:v.ladeuil+lp at free.fr-20071023105809-gtokg8o2zd0oeuyl
parent: v.ladeuil+lp at free.fr-20071023085109-60tarfj3wg23yd2a
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: auth.ring
timestamp: Tue 2007-10-23 12:58:09 +0200
message:
http can query AuthenticationConfig for logins too.
* bzrlib/transport/http/_urllib2_wrappers.py:
(AbstractAuthHandler.get_user_password): Renamed from get_pasword,
query AuthenticationConfig for user too, default to
getpass.getuser as other schemes.
modified:
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2007-10-23 08:51:09 +0000
+++ b/bzrlib/config.py 2007-10-23 10:58:09 +0000
@@ -63,7 +63,6 @@
"""
import os
-import getpass
import sys
from bzrlib.lazy_import import lazy_import
=== modified file 'bzrlib/transport/http/_urllib2_wrappers.py'
--- a/bzrlib/transport/http/_urllib2_wrappers.py 2007-10-23 08:51:09 +0000
+++ b/bzrlib/transport/http/_urllib2_wrappers.py 2007-10-23 10:58:09 +0000
@@ -938,21 +938,28 @@
# It may happen that we need to reconnect later, let's be ready
self._retry_count = None
- # FIXME: Rename get_credentials or something and query the auth config for
- # user too.
- def get_password(self, auth):
+ def get_user_password(self, auth):
"""Ask user for a password if none is already available."""
+ auth_conf = config.AuthenticationConfig()
user = auth['user']
- realm = auth['realm']
password = auth['password']
+ realm = auth['realm']
+
+ if user is None:
+ user = auth.get_user(auth['protocol'], auth['host'],
+ port=auth['port'], path=auth['path'],
+ realm=realm)
+ if user is None:
+ # Default to local user
+ user = getpass.getuser()
if password is None:
- auth_conf = config.AuthenticationConfig()
password = auth_conf.get_password(
auth['protocol'], auth['host'], user, port=auth['port'],
path=auth['path'], realm=realm,
prompt=self.build_password_prompt(auth))
- return password
+
+ return user, password
def _build_password_prompt(self, auth):
"""Build a prompt taking the protocol used into account.
@@ -1009,8 +1016,9 @@
# Put useful info into auth
self.update_auth(auth, 'scheme', scheme)
self.update_auth(auth, 'realm', realm)
- if auth.get('password',None) is None:
- password = self.get_password(auth)
+ if auth['user'] is None or auth['password'] is None:
+ user, password = self.get_user_password(auth)
+ self.update_auth(auth, 'user', user)
self.update_auth(auth, 'password', password)
return match is not None
@@ -1073,8 +1081,9 @@
# Put useful info into auth
self.update_auth(auth, 'scheme', scheme)
self.update_auth(auth, 'realm', realm)
- if auth.get('password',None) is None:
- password = self.get_password(auth)
+ if auth['user'] is None or auth['password'] is None:
+ user, password = self.get_user_password(auth)
+ self.update_auth(auth, 'user', user)
self.update_auth(auth, 'password', password)
try:
More information about the bazaar-commits
mailing list