From 31289cb156540a95dfe51737d9fd4e1a7393f2f2 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Goncalves Date: Wed, 20 Aug 2014 15:43:50 -0300 Subject: Added setup.py and changed app to pixelated because it will be a package --- service/pixelated/bitmask_libraries/auth.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 service/pixelated/bitmask_libraries/auth.py (limited to 'service/pixelated/bitmask_libraries/auth.py') diff --git a/service/pixelated/bitmask_libraries/auth.py b/service/pixelated/bitmask_libraries/auth.py new file mode 100644 index 00000000..0b963587 --- /dev/null +++ b/service/pixelated/bitmask_libraries/auth.py @@ -0,0 +1,27 @@ +from .leap_srp import LeapSecureRemotePassword +from .certs import which_bundle + +USE_PASSWORD = None + + +class LeapCredentials(object): + def __init__(self, user_name, password, db_passphrase=USE_PASSWORD): + self.user_name = user_name + self.password = password + self.db_passphrase = db_passphrase if db_passphrase is not None else password + + +class LeapAuthenticator(object): + def __init__(self, provider): + self._provider = provider + + def authenticate(self, credentials): + config = self._provider.config + srp = LeapSecureRemotePassword(ca_bundle=which_bundle(self._provider), timeout_in_s=config.timeout_in_s) + srp_session = srp.authenticate(self._provider.api_uri, credentials.user_name, credentials.password) + return srp_session + + def register(self, credentials): + config = self._provider.config + srp = LeapSecureRemotePassword(ca_bundle=which_bundle(self._provider), timeout_in_s=config.timeout_in_s) + srp.register(self._provider.api_uri, credentials.user_name, credentials.password) -- cgit v1.2.3