summaryrefslogtreecommitdiff
path: root/src/leap/base
diff options
context:
space:
mode:
authorkali <kali@leap.se>2013-01-11 03:00:41 +0900
committerkali <kali@leap.se>2013-01-11 03:00:41 +0900
commit6d85c97ddcc8a151b157919e9a7322fba151a551 (patch)
tree09df82613de44109352074dcf719e4c7b659a91c /src/leap/base
parentf55dcd717a946651492142ed198853b1c667254b (diff)
all calls except the first one are made to api uri
we also parse the port number
Diffstat (limited to 'src/leap/base')
-rw-r--r--src/leap/base/auth.py15
-rw-r--r--src/leap/base/config.py5
2 files changed, 10 insertions, 10 deletions
diff --git a/src/leap/base/auth.py b/src/leap/base/auth.py
index 563a0b2a..f629972f 100644
--- a/src/leap/base/auth.py
+++ b/src/leap/base/auth.py
@@ -43,7 +43,6 @@ class LeapSRPRegister(object):
def __init__(self,
schema="https",
provider=None,
- #port=None,
verify=True,
register_path="1/users.json",
method="POST",
@@ -56,11 +55,6 @@ class LeapSRPRegister(object):
self.schema = schema
- # XXX FIXME
- #self.provider = provider
- #self.port = port
- # XXX splitting server,port
- # deprecate port call.
domain, port = get_https_domain_and_port(provider)
self.provider = domain
self.port = port
@@ -137,6 +131,9 @@ class SRPAuth(requests.auth.AuthBase):
self.server = server
self.verify = verify
+ logger.debug('SRPAuth. verify=%s' % verify)
+ logger.debug('server: %s. username=%s' % (server, username))
+
self.init_data = None
self.session = requests.session()
@@ -168,6 +165,9 @@ class SRPAuth(requests.auth.AuthBase):
except requests.exceptions.ConnectionError:
raise SRPAuthenticationError(
"No connection made (salt).")
+ except:
+ raise SRPAuthenticationError(
+ "Unknown error (salt).")
if init_session.status_code not in (200, ):
raise SRPAuthenticationError(
"No valid response (salt).")
@@ -245,7 +245,6 @@ class SRPAuth(requests.auth.AuthBase):
try:
assert self.srp_usr.authenticated()
logger.debug('user is authenticated!')
- print 'user is authenticated!'
except (AssertionError):
raise SRPAuthenticationError(
"Auth verification failed.")
@@ -268,6 +267,8 @@ def srpauth_protected(user=None, passwd=None, server=None, verify=True):
auth = SRPAuth(user, passwd, server, verify)
kwargs['auth'] = auth
kwargs['verify'] = verify
+ if not args:
+ logger.warning('attempting to get from empty uri!')
return fn(*args, **kwargs)
return wrapper
return srpauth
diff --git a/src/leap/base/config.py b/src/leap/base/config.py
index 438d1993..e235e5c3 100644
--- a/src/leap/base/config.py
+++ b/src/leap/base/config.py
@@ -155,7 +155,7 @@ class JSONLeapConfig(BaseLeapConfig):
return False
def load(self, fromfile=None, from_uri=None, fetcher=None,
- force_download=False, verify=False):
+ force_download=False, verify=True):
if from_uri is not None:
fetched = self.fetch(
@@ -177,8 +177,7 @@ class JSONLeapConfig(BaseLeapConfig):
if not fetcher:
fetcher = self.fetcher
- logger.debug('verify: %s', verify)
- logger.debug('uri: %s', uri)
+ logger.debug('uri: %s (verify: %s)' % (uri, verify))
rargs = (uri, )
rkwargs = {'verify': verify}