diff options
author | kali <kali@leap.se> | 2012-10-26 00:12:08 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2012-10-26 00:12:08 +0900 |
commit | 0590991d7777de473a7df21ed32e1fa7caa9cf4b (patch) | |
tree | bb9ec79ffb49920f6e2abeef1d105c8d47e9a75f /src/leap | |
parent | a0fc20884a02ccffe1f9a83440b5e2212853289a (diff) |
user credentials saved on login/signup branches.
cert request is using magick decorator that retrieves the certificates
using srp.
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/base/auth.py | 37 | ||||
-rw-r--r-- | src/leap/crypto/leapkeyring.py | 1 | ||||
-rw-r--r-- | src/leap/eip/checks.py | 5 | ||||
-rwxr-xr-x | src/leap/gui/firstrunwizard.py | 21 |
4 files changed, 35 insertions, 29 deletions
diff --git a/src/leap/base/auth.py b/src/leap/base/auth.py index cc9562d8..1665f48e 100644 --- a/src/leap/base/auth.py +++ b/src/leap/base/auth.py @@ -1,7 +1,7 @@ import binascii import json import logging -import urlparse +#import urlparse import requests import srp @@ -9,6 +9,7 @@ import srp from PyQt4 import QtCore from leap.base import constants as baseconstants +from leap.crypto import leapkeyring logger = logging.getLogger(__name__) @@ -159,7 +160,7 @@ class SRPAuth(requests.auth.AuthBase): return self.init_data def authenticate(self): - print 'start authentication...' + logger.debug('start authentication...') init_data = self.get_init_data() salt = init_data.get('salt', None) @@ -190,7 +191,7 @@ class SRPAuth(requests.auth.AuthBase): try: assert self.srp_usr.authenticated() - print 'user is authenticated!' + logger.debug('user is authenticated!') except (AssertionError): raise SRPAuthenticationError @@ -217,34 +218,32 @@ def srpauth_protected(user=None, passwd=None): return srpauth -def magic_srpauth(fn): +def get_leap_credentials(): + settings = QtCore.QSettings() + full_username = settings.value('eip_username') + username, domain = full_username.split('@') + seed = settings.value('%s_seed' % domain, None) + password = leapkeyring.leap_get_password(full_username, seed=seed) + return (username, password) + + +def magick_srpauth(fn): """ decorator that gets user and password from the config file and adds those to the decorated request """ - # TODO --- finish this... - # currently broken. + logger.debug('magick srp auth decorator called') + def wrapper(*args, **kwargs): - uri = args[0] + #uri = args[0] # XXX Ugh! # Problem with this approach. # This won't work when we're using # api.foo.bar # Unless we keep a table with the # equivalencies... - - domain = urlparse.urlparse(uri).netloc - - # XXX check this settings init... - settings = QtCore.QSettings() - user = settings.get('%s_username' % domain, None) - - # uh... I forgot. - # get secret? - # leapkeyring.get_password(foo?) - passwd = settings.get('%s_password' % domain, None) - + user, passwd = get_leap_credentials() auth = SRPAuth(user, passwd) kwargs['auth'] = auth return fn(*args, **kwargs) diff --git a/src/leap/crypto/leapkeyring.py b/src/leap/crypto/leapkeyring.py index bceadc75..d4be7bf9 100644 --- a/src/leap/crypto/leapkeyring.py +++ b/src/leap/crypto/leapkeyring.py @@ -59,6 +59,7 @@ def leap_set_password(key, value, seed="xxx"): def leap_get_password(key, seed="xxx"): keyring.set_keyring(LeapCryptedFileKeyring(seed=seed)) + #import ipdb;ipdb.set_trace() return keyring.get_password('leap', key) diff --git a/src/leap/eip/checks.py b/src/leap/eip/checks.py index cd9d9972..ae3634bc 100644 --- a/src/leap/eip/checks.py +++ b/src/leap/eip/checks.py @@ -11,7 +11,7 @@ import requests from leap import __branding as BRANDING from leap import certs as leapcerts -from leap.base.auth import srpauth_protected +from leap.base.auth import srpauth_protected, magick_srpauth from leap.base import config as baseconfig from leap.base import constants as baseconstants from leap.base import providers @@ -217,8 +217,7 @@ class ProviderCertChecker(object): return fgetfn(*args, **kwargs) else: - # XXX use magic_srpauth decorator instead, - # merge with the branch above + @magick_srpauth def getfn(*args, **kwargs): return fgetfn(*args, **kwargs) try: diff --git a/src/leap/gui/firstrunwizard.py b/src/leap/gui/firstrunwizard.py index 78f8afb5..4cad9c3f 100755 --- a/src/leap/gui/firstrunwizard.py +++ b/src/leap/gui/firstrunwizard.py @@ -28,10 +28,7 @@ except ImportError: # We must be in 2.6 from leap.util.dicts import OrderedDict -# XXX DEBUG -logging.basicConfig() logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) APP_LOGO = ':/images/leap-color-small.png' @@ -194,22 +191,32 @@ class FirstRunWizard(QtGui.QWizard): gather the info, update settings and call the success callback if any has been passed. """ + super(FirstRunWizard, self).accept() + + # username and password are in different fields + # if they were stored in log_in or sign_up pages. + from_login = self.wizard().from_login + unamek_base = 'userName' + passwk_base = 'userPassword' + unamek = 'login_%s' % unamek_base if from_login else unamek_base + passwk = 'login_%s' % passwk_base if from_login else passwk_base + + username = self.field(unamek) + password = self.field(passwk) provider = self.field('provider_domain') - username = self.field('userName') - password = self.field('userPassword') remember_pass = self.field('rememberPassword') logger.debug('chosen provider: %s', provider) logger.debug('username: %s', username) logger.debug('remember password: %s', remember_pass) - super(FirstRunWizard, self).accept() - settings = QtCore.QSettings() # we are assuming here that we only remember one username # in the form username@provider.domain # We probably could extend this to support some form of # profiles. + settings = QtCore.QSettings() + settings.setValue("FirstRunWizardDone", True) settings.setValue("provider_domain", provider) full_username = "%s@%s" % (username, provider) |