summaryrefslogtreecommitdiff
path: root/src/leap/base/auth.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/base/auth.py')
-rw-r--r--src/leap/base/auth.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/leap/base/auth.py b/src/leap/base/auth.py
index ecc24179..c2d3f424 100644
--- a/src/leap/base/auth.py
+++ b/src/leap/base/auth.py
@@ -43,9 +43,8 @@ class LeapSRPRegister(object):
def __init__(self,
schema="https",
provider=None,
- #port=None,
verify=True,
- register_path="1/users.json",
+ register_path="1/users",
method="POST",
fetcher=requests,
srp=srp,
@@ -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
@@ -119,9 +113,6 @@ class LeapSRPRegister(object):
uri, data=user_data,
timeout=SIGNUP_TIMEOUT,
verify=self.verify)
- logger.debug(req)
- logger.debug('user_data: %s', user_data)
- #logger.debug('response: %s', req.text)
# we catch it in the form
#req.raise_for_status()
return (req.ok, req)
@@ -137,6 +128,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()
@@ -162,12 +156,15 @@ class SRPAuth(requests.auth.AuthBase):
def get_init_data(self):
try:
init_session = self.session.post(
- self.server + '/1/sessions.json/',
+ self.server + '/1/sessions/',
data=self.get_auth_data(),
verify=self.verify)
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 +242,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 +264,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
@@ -275,7 +273,7 @@ def srpauth_protected(user=None, passwd=None, server=None, verify=True):
def get_leap_credentials():
settings = QtCore.QSettings()
- full_username = settings.value('eip_username')
+ full_username = settings.value('username')
username, domain = full_username.split('@')
seed = settings.value('%s_seed' % domain, None)
password = leapkeyring.leap_get_password(full_username, seed=seed)