summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/bonafide/_http.py1
-rw-r--r--src/leap/bonafide/_srp.py6
-rwxr-xr-xsrc/leap/bonafide/bonafide_cli2
-rw-r--r--src/leap/bonafide/provider.py2
-rw-r--r--src/leap/bonafide/session.py16
5 files changed, 23 insertions, 4 deletions
diff --git a/src/leap/bonafide/_http.py b/src/leap/bonafide/_http.py
index 39aabab..b92cf57 100644
--- a/src/leap/bonafide/_http.py
+++ b/src/leap/bonafide/_http.py
@@ -50,6 +50,7 @@ def httpRequest(agent, url, values={}, headers={}, method='POST', token=None):
headers['Authorization'] = ['Token token="%s"' % (bytes(token))]
def handle_response(response):
+ print "RESPONSE CODE", response.code
if response.code == 204:
d = defer.succeed('')
else:
diff --git a/src/leap/bonafide/_srp.py b/src/leap/bonafide/_srp.py
index dc856ab..4f4a605 100644
--- a/src/leap/bonafide/_srp.py
+++ b/src/leap/bonafide/_srp.py
@@ -32,8 +32,7 @@ class SRPAuthMechanism(object):
"""
def initialize(self, username, password):
- srp_user = srp.User(username.encode('utf-8'),
- password.encode('utf-8'),
+ srp_user = srp.User(username, password,
srp.SHA256, srp.NG_1024)
_, A = srp_user.start_authentication()
return srp_user, A
@@ -71,7 +70,7 @@ class SRPAuthMechanism(object):
def _check_for_errors(self, response):
if 'errors' in response:
msg = response['errors']['base']
- raise SRPAuthError(msg)
+ raise SRPAuthError(unicode(msg).encode('utf-8'))
def _unhex_salt_B(self, salt, B):
if salt is None:
@@ -142,4 +141,3 @@ class SRPAuthBadDataFromServer(SRPAuthError):
class SRPRegistrationError(Exception):
pass
-
diff --git a/src/leap/bonafide/bonafide_cli b/src/leap/bonafide/bonafide_cli
index 64aa6ad..15a7a00 100755
--- a/src/leap/bonafide/bonafide_cli
+++ b/src/leap/bonafide/bonafide_cli
@@ -53,6 +53,8 @@ def _display_token(result, _session):
if result == session.OK:
print('[ok] token--> ' + Fore.GREEN +
_session.token + Fore.RESET)
+ print('[ok] uuid --> ' + Fore.GREEN +
+ _session.uuid + Fore.RESET)
def _display_registered(result, _session, _provider):
ok, user = result
diff --git a/src/leap/bonafide/provider.py b/src/leap/bonafide/provider.py
index 470b413..c22be3c 100644
--- a/src/leap/bonafide/provider.py
+++ b/src/leap/bonafide/provider.py
@@ -79,6 +79,8 @@ class Api(object):
An object that has all the information that a client needs to communicate
with the remote methods exposed by the web API of a LEAP provider.
+ The actions are described in https://leap.se/bonafide
+
By using the _MetaActionDispatcher as a metaclass, the _actions dict will be
translated dynamically into a set of instance methods that will allow
getting the uri and method for each action.
diff --git a/src/leap/bonafide/session.py b/src/leap/bonafide/session.py
index 6b60b6a..4fa3299 100644
--- a/src/leap/bonafide/session.py
+++ b/src/leap/bonafide/session.py
@@ -61,6 +61,10 @@ class Session(object):
return self._token
@property
+ def uuid(self):
+ return self._uuid
+
+ @property
def is_authenticated(self):
if not self._srp_user:
return False
@@ -98,10 +102,16 @@ class Session(object):
defer.returnValue(OK)
@auth_required
+ @defer.inlineCallbacks
def logout(self):
+ uri = self._api.get_logout_uri()
+ met = self._api.get_logout_method()
+ auth = yield self._request(self._agent, uri, method=met)
+ print "AUTH RESULT->", auth
self.username = None
self.password = None
self._initialize_session()
+ defer.returnValue(OK)
# User certificates
@@ -177,6 +187,12 @@ if __name__ == "__main__":
d = session.authenticate()
d.addCallback(print_result)
d.addErrback(auth_eb)
+
+ d.addCallback(lambda _: session.get_smtp_cert())
+ #d.addCallback(lambda _: session.get_vpn_cert())
+ d.addCallback(print_result)
+ d.addErrback(auth_eb)
+
d.addCallback(lambda _: session.logout())
d.addErrback(auth_eb)
d.addBoth(cbShutDown)