diff options
author | Bruno Wagner Goncalves <bwagner@thoughtworks.com> | 2014-08-20 15:43:50 -0300 |
---|---|---|
committer | Bruno Wagner Goncalves <bwagner@thoughtworks.com> | 2014-08-20 18:27:01 -0300 |
commit | 31289cb156540a95dfe51737d9fd4e1a7393f2f2 (patch) | |
tree | 238480ca562c9c65e1aeaaeaebe063549b3718f4 /service/pixelated/bitmask_libraries/auth.py | |
parent | 02df978f9faa4a00b07d2c70d3bd47a25287d0e1 (diff) |
Added setup.py and changed app to pixelated because it will be a package
Diffstat (limited to 'service/pixelated/bitmask_libraries/auth.py')
-rw-r--r-- | service/pixelated/bitmask_libraries/auth.py | 27 |
1 files changed, 27 insertions, 0 deletions
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) |