diff options
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/config/authentication.py | 11 | ||||
-rw-r--r-- | service/pixelated/config/leap.py | 8 | ||||
-rw-r--r-- | service/pixelated/resources/auth.py | 4 |
3 files changed, 17 insertions, 6 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(): diff --git a/service/pixelated/resources/auth.py b/service/pixelated/resources/auth.py index 5581d080..66aac4e5 100644 --- a/service/pixelated/resources/auth.py +++ b/service/pixelated/resources/auth.py @@ -17,7 +17,6 @@ import logging import re -from leap.exceptions import SRPAuthenticationError from twisted.cred.checkers import ANONYMOUS from twisted.cred.credentials import ICredentials from twisted.cred.error import UnauthorizedLogin @@ -30,6 +29,7 @@ from twisted.web import util from twisted.cred import error from twisted.web.resource import IResource, ErrorPage +from leap.bonafide._srp import SRPAuthError from pixelated.config.leap import create_leap_session, authenticate from pixelated.resources import IPixelatedSession @@ -50,7 +50,7 @@ class LeapPasswordChecker(object): def requestAvatarId(self, credentials): try: auth = yield authenticate(self.provider, credentials.username, credentials.password) - except SRPAuthenticationError: + except SRPAuthError: raise UnauthorizedLogin() leap_session = yield create_leap_session(self.provider, credentials.username, credentials.password, auth) |