summaryrefslogtreecommitdiff
path: root/service/pixelated/config
diff options
context:
space:
mode:
authorTulio Casagrande <tcasagra@thoughtworks.com>2016-09-23 15:28:59 -0300
committerTulio Casagrande <tcasagra@thoughtworks.com>2016-09-23 15:38:47 -0300
commit62e7904d8791a600474ca6491db75eb9102a1093 (patch)
tree180235903c9c0d195083f89fb740f641218a7319 /service/pixelated/config
parente2cb0deda1e0668dd23e0fefc8020d10c1cad488 (diff)
Replace SRPSession usages with bonafide
In order to replace leap_auth with bonafide, we created a class to hold the user credentials
Diffstat (limited to 'service/pixelated/config')
-rw-r--r--service/pixelated/config/authentication.py11
-rw-r--r--service/pixelated/config/leap.py8
2 files changed, 15 insertions, 4 deletions
diff --git a/service/pixelated/config/authentication.py b/service/pixelated/config/authentication.py
new file mode 100644
index 00000000..dc8439cc
--- /dev/null
+++ b/service/pixelated/config/authentication.py
@@ -0,0 +1,11 @@
+class Authentication(object):
+
+ def __init__(self, username, token, uuid, session_id, user_attributes):
+ self.username = username
+ self.token = token
+ self.uuid = uuid
+ self.session_id = session_id
+ self._user_attributes = user_attributes
+
+ def is_admin(self):
+ return self._user_attributes.get('is_admin', False)
diff --git a/service/pixelated/config/leap.py b/service/pixelated/config/leap.py
index 22c1e57a..54518bae 100644
--- a/service/pixelated/config/leap.py
+++ b/service/pixelated/config/leap.py
@@ -4,12 +4,12 @@ from collections import namedtuple
from twisted.internet import defer, threads
from leap.common.events import (server as events_server)
from leap.soledad.common.errors import InvalidAuthTokenError
-from leap.auth import SRPSession
-
+from leap.bonafide._srp import SRPAuthError
from leap.bonafide.session import Session
from leap.bonafide.provider import Api
from pixelated.config import credentials
from pixelated.config import leap_config
+from pixelated.config.authentication import Authentication
from pixelated.bitmask_libraries.certs import LeapCertificate
from pixelated.bitmask_libraries.provider import LeapProvider
from pixelated.config.sessions import LeapSessionFactory
@@ -73,7 +73,7 @@ def initialize_leap_single_user(leap_provider_cert,
try:
auth = yield authenticate(provider, username, password)
- except SRPAuthenticationError:
+ except SRPAuthError:
raise UnauthorizedLogin()
leap_session = yield create_leap_session(provider, username, password, auth)
@@ -87,7 +87,7 @@ def authenticate(provider, user, password):
credentials = Credentials(user, password)
srp_auth = Session(credentials, srp_provider, provider.local_ca_crt)
yield srp_auth.authenticate()
- defer.returnValue(SRPSession(user, srp_auth.token, srp_auth.uuid, 'session_id', {'is_admin': False}))
+ defer.returnValue(Authentication(user, srp_auth.token, srp_auth.uuid, 'session_id', {'is_admin': False}))
def init_monkeypatches():