From ad16a72f60ecc84524c22e8912df4eb8a48a2a42 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 6 Nov 2012 16:26:10 +0900 Subject: split wizard into separate files so we don't go nuts yet. --- src/leap/gui/firstrun/providersetup.py | 122 +++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 src/leap/gui/firstrun/providersetup.py (limited to 'src/leap/gui/firstrun/providersetup.py') diff --git a/src/leap/gui/firstrun/providersetup.py b/src/leap/gui/firstrun/providersetup.py new file mode 100644 index 00000000..63f55d00 --- /dev/null +++ b/src/leap/gui/firstrun/providersetup.py @@ -0,0 +1,122 @@ +""" +Provider Setup Validation Page, +used if First Run Wizard +""" + +from PyQt4 import QtGui + +from leap.gui.progress import ValidationPage + +from leap.gui.constants import APP_LOGO + + +class ProviderSetupValidationPage(ValidationPage): + def __init__(self, parent=None): + super(ProviderSetupValidationPage, self).__init__(parent) + self.setTitle("Setting up provider") + #self.setSubTitle( + #"auto configuring provider...") + + self.setPixmap( + QtGui.QWizard.LogoPixmap, + QtGui.QPixmap(APP_LOGO)) + + def _do_checks(self, signal=None): + """ + executes actual checks in a separate thread + """ + import time + domain = self.field('provider_domain') + wizard = self.wizard() + pconfig = wizard.providerconfig + + pCertChecker = wizard.providercertchecker + certchecker = pCertChecker(domain=domain) + + signal.emit('Fetching CA certificate') + self.progress.setValue(30) + + if pconfig: + ca_cert_uri = pconfig.get('ca_cert_uri').geturl() + else: + ca_cert_uri = None + + # XXX check scheme == "https" + # XXX passing verify == False because + # we have trusted right before. + # We should check it's the same domain!!! + # (Check with the trusted fingerprints dict + # or something smart) + + #certchecker.download_ca_cert( + #uri=ca_cert_uri, + #verify=False) + + time.sleep(2) + + signal.emit('Checking CA fingerprint') + self.progress.setValue(66) + #ca_cert_fingerprint = pconfig.get('ca_cert_fingerprint', None) + + # XXX get fingerprint dict (types) + #sha256_fpr = ca_cert_fingerprint.split('=')[1] + + #validate_fpr = certchecker.check_ca_cert_fingerprint( + #fingerprint=sha256_fpr) + time.sleep(0.5) + #if not validate_fpr: + # XXX update validationMsg + # should catch exception + #return False + + signal.emit('Validating api certificate') + self.progress.setValue(90) + + #api_uri = pconfig.get('api_uri', None) + #try: + #api_cert_verified = certchecker.verify_api_https(api_uri) + #except requests.exceptions.SSLError as exc: + #logger.error('BUG #638. %s' % exc.message) + # XXX RAISE! See #638 + # bypassing until the hostname is fixed. + # We probably should raise yet-another-warning + # here saying user that the hostname "XX.XX.XX.XX' does not + # match 'foo.bar.baz' + #api_cert_verified = True + + #if not api_cert_verified: + # XXX update validationMsg + # should catch exception + #return False + time.sleep(0.5) + #ca_cert_path = checker.ca_cert_path + + self.progress.setValue(100) + signal.emit('end_sentinel') + time.sleep(1) + + def _do_validation(self): + """ + called after _do_checks has finished + (connected to checker thread finished signal) + """ + wizard = self.wizard() + if self.errors: + print 'going back with errors' + wizard.set_validation_error( + 'signup', 'that name is taken') + self.go_back() + else: + print 'going next' + self.go_next() + + def nextId(self): + wizard = self.wizard() + if not wizard: + return + is_signup = self.field('is_signup') + if is_signup is True: + next_ = 'signup' + if is_signup is False: + next_ = 'connecting' + return wizard.get_page_index(next_) -- cgit v1.2.3 From 6032f776cabcd04aa7f4e1f55a34ecfec2775e85 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 7 Nov 2012 04:48:12 +0900 Subject: changes to update_signal + Fix update + Rename + Changed signature (we update progress bar from slot now) --- src/leap/gui/firstrun/providersetup.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/leap/gui/firstrun/providersetup.py') diff --git a/src/leap/gui/firstrun/providersetup.py b/src/leap/gui/firstrun/providersetup.py index 63f55d00..c039dfc5 100644 --- a/src/leap/gui/firstrun/providersetup.py +++ b/src/leap/gui/firstrun/providersetup.py @@ -21,7 +21,7 @@ class ProviderSetupValidationPage(ValidationPage): QtGui.QWizard.LogoPixmap, QtGui.QPixmap(APP_LOGO)) - def _do_checks(self, signal=None): + def _do_checks(self, update_signal=None): """ executes actual checks in a separate thread """ @@ -33,8 +33,7 @@ class ProviderSetupValidationPage(ValidationPage): pCertChecker = wizard.providercertchecker certchecker = pCertChecker(domain=domain) - signal.emit('Fetching CA certificate') - self.progress.setValue(30) + update_signal.emit('Fetching CA certificate', 30) if pconfig: ca_cert_uri = pconfig.get('ca_cert_uri').geturl() @@ -54,8 +53,7 @@ class ProviderSetupValidationPage(ValidationPage): time.sleep(2) - signal.emit('Checking CA fingerprint') - self.progress.setValue(66) + update_signal.emit('Checking CA fingerprint', 66) #ca_cert_fingerprint = pconfig.get('ca_cert_fingerprint', None) # XXX get fingerprint dict (types) @@ -69,8 +67,7 @@ class ProviderSetupValidationPage(ValidationPage): # should catch exception #return False - signal.emit('Validating api certificate') - self.progress.setValue(90) + update_signal.emit('Validating api certificate', 90) #api_uri = pconfig.get('api_uri', None) #try: @@ -91,8 +88,7 @@ class ProviderSetupValidationPage(ValidationPage): time.sleep(0.5) #ca_cert_path = checker.ca_cert_path - self.progress.setValue(100) - signal.emit('end_sentinel') + update_signal.emit('end_sentinel', 100) time.sleep(1) def _do_validation(self): -- cgit v1.2.3 From b84007d8fec8c949ba4ac1d26695c710a210d797 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 8 Nov 2012 08:37:24 +0900 Subject: more careful error catching during registration. added a twisted server that fakes some of the provider interaction. --- src/leap/gui/firstrun/providersetup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/leap/gui/firstrun/providersetup.py') diff --git a/src/leap/gui/firstrun/providersetup.py b/src/leap/gui/firstrun/providersetup.py index c039dfc5..2609629a 100644 --- a/src/leap/gui/firstrun/providersetup.py +++ b/src/leap/gui/firstrun/providersetup.py @@ -100,7 +100,8 @@ class ProviderSetupValidationPage(ValidationPage): if self.errors: print 'going back with errors' wizard.set_validation_error( - 'signup', 'that name is taken') + 'providerselection', + 'error on provider setup') self.go_back() else: print 'going next' -- cgit v1.2.3 From 6dac344ee1826f9413a40c7783517bc640f826ca Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 12 Nov 2012 22:09:05 +0900 Subject: uncomment download_ca_cert call --- src/leap/gui/firstrun/providersetup.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/leap/gui/firstrun/providersetup.py') diff --git a/src/leap/gui/firstrun/providersetup.py b/src/leap/gui/firstrun/providersetup.py index 2609629a..a1710a3a 100644 --- a/src/leap/gui/firstrun/providersetup.py +++ b/src/leap/gui/firstrun/providersetup.py @@ -7,7 +7,7 @@ from PyQt4 import QtGui from leap.gui.progress import ValidationPage -from leap.gui.constants import APP_LOGO +from leap.gui.constants import APP_LOGO, pause_for_user class ProviderSetupValidationPage(ValidationPage): @@ -25,7 +25,6 @@ class ProviderSetupValidationPage(ValidationPage): """ executes actual checks in a separate thread """ - import time domain = self.field('provider_domain') wizard = self.wizard() pconfig = wizard.providerconfig @@ -33,7 +32,9 @@ class ProviderSetupValidationPage(ValidationPage): pCertChecker = wizard.providercertchecker certchecker = pCertChecker(domain=domain) + update_signal.emit('head_sentinel', 0) update_signal.emit('Fetching CA certificate', 30) + pause_for_user() if pconfig: ca_cert_uri = pconfig.get('ca_cert_uri').geturl() @@ -47,11 +48,10 @@ class ProviderSetupValidationPage(ValidationPage): # (Check with the trusted fingerprints dict # or something smart) - #certchecker.download_ca_cert( - #uri=ca_cert_uri, - #verify=False) - - time.sleep(2) + certchecker.download_ca_cert( + uri=ca_cert_uri, + verify=False) + pause_for_user() update_signal.emit('Checking CA fingerprint', 66) #ca_cert_fingerprint = pconfig.get('ca_cert_fingerprint', None) @@ -61,7 +61,6 @@ class ProviderSetupValidationPage(ValidationPage): #validate_fpr = certchecker.check_ca_cert_fingerprint( #fingerprint=sha256_fpr) - time.sleep(0.5) #if not validate_fpr: # XXX update validationMsg # should catch exception @@ -85,11 +84,11 @@ class ProviderSetupValidationPage(ValidationPage): # XXX update validationMsg # should catch exception #return False - time.sleep(0.5) + pause_for_user() #ca_cert_path = checker.ca_cert_path update_signal.emit('end_sentinel', 100) - time.sleep(1) + pause_for_user() def _do_validation(self): """ -- cgit v1.2.3 From 971c5e2217d17f4dab68336c9d8f562ca63fc84b Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 13 Nov 2012 00:14:53 +0900 Subject: check credentials on login branch plus fix repaint on populateErrors on login page, should refactor to ToBeValidated class or something similar, with the other paintEvent functions that implement the painting of errors coming from the "next" validating page. --- src/leap/gui/firstrun/providersetup.py | 75 +++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 11 deletions(-) (limited to 'src/leap/gui/firstrun/providersetup.py') diff --git a/src/leap/gui/firstrun/providersetup.py b/src/leap/gui/firstrun/providersetup.py index a1710a3a..3fb9a19b 100644 --- a/src/leap/gui/firstrun/providersetup.py +++ b/src/leap/gui/firstrun/providersetup.py @@ -2,17 +2,24 @@ Provider Setup Validation Page, used if First Run Wizard """ +import logging from PyQt4 import QtGui +from leap.base import auth from leap.gui.progress import ValidationPage from leap.gui.constants import APP_LOGO, pause_for_user +logger = logging.getLogger(__name__) + class ProviderSetupValidationPage(ValidationPage): def __init__(self, parent=None): super(ProviderSetupValidationPage, self).__init__(parent) + is_signup = self.field("is_signup") + self.is_signup = is_signup + self.setTitle("Setting up provider") #self.setSubTitle( #"auto configuring provider...") @@ -25,14 +32,56 @@ class ProviderSetupValidationPage(ValidationPage): """ executes actual checks in a separate thread """ - domain = self.field('provider_domain') + full_domain = self.field('provider_domain') wizard = self.wizard() pconfig = wizard.providerconfig - pCertChecker = wizard.providercertchecker - certchecker = pCertChecker(domain=domain) + #pCertChecker = wizard.providercertchecker + #certchecker = pCertChecker(domain=full_domain) + pCertChecker = wizard.providercertchecker( + domain=full_domain) update_signal.emit('head_sentinel', 0) + + ###################################### + if not self.is_signup: + # We come from login page. + # We try a call to an authenticated + # page here as a mean to catch + # srp authentication errors while + # we are still at one page's reach + # of the login credentials input page. + # (so we're able to go back an correct) + + step = "fetch_eipcert" + update_signal.emit('validating credentials', 20) + + unamek = 'login_userName' + passwk = 'login_userPassword' + + username = self.field(unamek) + password = self.field(passwk) + credentials = username, password + + ################# + # FIXME #BUG #638 + verify = False + + try: + pCertChecker.download_new_client_cert( + credentials=credentials, + verify=verify) + + except auth.SRPAuthenticationError as exc: + self.set_error( + step, + "Authentication error: %s" % exc.message) + return False + + pause_for_user() + + ####################################### + update_signal.emit('Fetching CA certificate', 30) pause_for_user() @@ -48,7 +97,7 @@ class ProviderSetupValidationPage(ValidationPage): # (Check with the trusted fingerprints dict # or something smart) - certchecker.download_ca_cert( + pCertChecker.download_ca_cert( uri=ca_cert_uri, verify=False) pause_for_user() @@ -59,7 +108,7 @@ class ProviderSetupValidationPage(ValidationPage): # XXX get fingerprint dict (types) #sha256_fpr = ca_cert_fingerprint.split('=')[1] - #validate_fpr = certchecker.check_ca_cert_fingerprint( + #validate_fpr = pCertChecker.check_ca_cert_fingerprint( #fingerprint=sha256_fpr) #if not validate_fpr: # XXX update validationMsg @@ -70,7 +119,7 @@ class ProviderSetupValidationPage(ValidationPage): #api_uri = pconfig.get('api_uri', None) #try: - #api_cert_verified = certchecker.verify_api_https(api_uri) + #api_cert_verified = pCertChecker.verify_api_https(api_uri) #except requests.exceptions.SSLError as exc: #logger.error('BUG #638. %s' % exc.message) # XXX RAISE! See #638 @@ -95,15 +144,18 @@ class ProviderSetupValidationPage(ValidationPage): called after _do_checks has finished (connected to checker thread finished signal) """ + prevpage = "providerselection" if self.is_signup else "login" wizard = self.wizard() + if self.errors: - print 'going back with errors' + logger.debug('going back with errors') + name, first_error = self.pop_first_error() wizard.set_validation_error( - 'providerselection', - 'error on provider setup') + prevpage, + first_error) self.go_back() else: - print 'going next' + logger.debug('going next') self.go_next() def nextId(self): @@ -114,5 +166,6 @@ class ProviderSetupValidationPage(ValidationPage): if is_signup is True: next_ = 'signup' if is_signup is False: - next_ = 'connecting' + # XXX bad name. change to connect again. + next_ = 'signupvalidation' return wizard.get_page_index(next_) -- cgit v1.2.3