def do_login(self):
        r = self.request(
            '/api/auth/login', data={
                'device_id': "1",
                'email_address': self.config['credentials']['email'],
                'password': self.config['credentials']['password'],
            }
        )

        if 'error' in r:
            raise BrowserIncorrectPassword()

        self.session.headers['Authorization'] = 'Bearer %s' % r['data']['token']
Beispiel #2
0
    def do_login(self):
        """
        Attempt to log in.
        Note: this method does nothing if we are already logged in.
        """
        assert isinstance(self.username, basestring)
        assert isinstance(self.password, basestring)
        self.login.go()

        self.page.login(self.username, self.password)

        if not self.index.is_here():
            raise BrowserIncorrectPassword()
Beispiel #3
0
 def do_login(self):
     assert isinstance(self.username, basestring)
     assert isinstance(self.password, basestring)
     self.login.stay_or_go()
     assert self.login.is_here()
     self.page.login(self.type, self.username, self.password)
     if self.error.is_here() or self.page.is_error():
         raise BrowserIncorrectPassword()
     if self.type == '2' and self.page.is_corporate():
         raise SiteSwitch('corporate')
     # ti corporate and ge corporate are not detected the same way ..
     if 'corporate' in self.page.url:
         self.is_corporate = True
Beispiel #4
0
    def do_login(self):
        if not self.login.is_here():
            self.login.go()

        self.page.login(self.username, self.password)

        if self.login.is_here():
            raise BrowserIncorrectPassword()

        divs = self.page.doc.xpath('//div[@id="loggedas"]')
        if len(divs) > 0:
            parts = divs[0].find('a').attrib['href'].split('/')
            self._userid = int(parts[2])
Beispiel #5
0
    def do_login(self):
        # Clear cookies.
        self.do_logout()

        self.login.go()

        if not self.page.logged:
            self.page.login(self.username, self.password)

            if not self.page.logged or self.login_error.is_here():
                raise BrowserIncorrectPassword()

        self.getCurrentSubBank()
Beispiel #6
0
    def do_login(self):
        self.session.cookies.clear()

        self.app_gone = False
        # The website seems to be using the connection2 URL now for login, it seems weird
        # that there is randomly 2 `/` in the URL so i let the try on the first connection
        # in case they revert the change.
        try:
            self.connection.go()
        except HTTPNotFound:
            self.connection2.go()

        self.page.login(self.username)

        no_secure_key_link = self.page.get_no_secure_key()

        if not no_secure_key_link:
            raise BrowserIncorrectPassword()
        self.location(no_secure_key_link)

        self.page.login_w_secure(self.password, self.secret)
        for _ in range(3):
            if self.login.is_here():
                self.page.useless_form()

        # This wonderful website has 2 baseurl with only one difference: the 's' at the end of 'client'
        new_base_url = 'https://clients.hsbc.fr/'
        if new_base_url in self.url:
            self.BASEURL = new_base_url

        if self.frame_page.is_here():
            self.home_url = self.page.get_frame()
            self.js_url = self.page.get_js_url()

        if not self.home_url or not self.page.logged:
            raise BrowserIncorrectPassword()

        self.location(self.home_url)
Beispiel #7
0
    def do_login(self):
        if not (self.login_page.is_here() or self.login2.is_here()):
            self.location(self.URLS[self.website]['login'])

        self.page.login(self.username, self.password)

        assert self.login_result.is_here() or self.empty_page.is_here()

        if self.login_result.is_here():
            error = self.page.get_error()
            if error is not None:
                raise BrowserIncorrectPassword(error)

            self.page.confirm()
Beispiel #8
0
    def do_login(self):
        assert isinstance(self.username, basestring)
        assert isinstance(self.password, basestring)
        assert self.password.isdigit()

        self.login.stay_or_go()
        self.session.cookies.set('PILOTE_OOBA', 'true')
        self.page.login(self.username, self.password)

        # force page change
        if not self.accounts.is_here():
            self.go_accounts()
        if not self.is_logged():
            raise BrowserIncorrectPassword()
Beispiel #9
0
 def on_load(self):
     self.browser.open(
         "https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/securite/authentification/verifierMotDePasse-identif.ea"
     )
     if self.doc.xpath(
             u'//span[contains(text(), "L\'identifiant utilisé est celui d\'une Entreprise ou d\'une Association")]'
     ):
         raise BrowserIncorrectPassword(
             u"L'identifiant utilisé est celui d'une Entreprise ou d'une Association"
         )
     no_accounts = CleanText(u'//div[@class="textFCK"]')(self.doc)
     if no_accounts:
         raise NoAccountsException(no_accounts)
     MyHTMLPage.on_load(self)
Beispiel #10
0
    def do_login(self):
        data = {
            'username': self.username,
            'password': self.password,
            'grant_type': 'password'
        }

        try:
            result = self.request('/oauth/token', data=data, method="POST")
        except ClientError:
            raise BrowserIncorrectPassword()

        self.auth_method = 'bearer'
        self.bearer = result['access_token']
Beispiel #11
0
    def login_w_secure(self, password, secret):
        form = self.get_form(nr=0)
        form['memorableAnswer'] = secret
        inputs = self.doc.xpath(u'//input[starts-with(@id, "keyrcc_password_first")]')
        split_pass = u''
        if len(password) != len(inputs):
            raise BrowserIncorrectPassword('Your password must be %d chars long' % len(inputs))

        for i, inpu in enumerate(inputs):
            # The good field are 1,2,3 and the bad one are 11,12,21,23,24,31 and so one
            if int(inpu.attrib['id'].split('first')[1]) < 10:
                split_pass += password[i]
        form['password'] = split_pass
        form.submit()
Beispiel #12
0
    def do_login(self):
        if not self.login_page.is_here():
            self.location('/fr/identification.jsp')

        self.page.login(self.username, self.password)

        if self.login_page.is_here():
            self.page.check_is_blocked()
            raise BrowserIncorrectPassword()

        self.location('/fr/prive/default.jsp?ANav=1')
        if self.accounts_page.is_here() and self.page.need_sms():
            raise AuthMethodNotImplemented(
                'Authentification with sms is not supported')
Beispiel #13
0
    def do_login(self):
        """
        Attempt to log in.
        Note: this method does nothing if we are already logged in.
        """
        assert isinstance(self.username, basestring)
        assert isinstance(self.password, basestring)

        try:
            self.login.go(data=json.dumps({'username' : self.username, 'password' : self.password}), \
                          headers={'Content-Type': 'application/json;charset=UTF-8'})
            self.token = self.authorize.go().get_token()
        except ClientError:
            raise BrowserIncorrectPassword()
Beispiel #14
0
    def do_login(self):
        try:
            self.signin.go(data={
                'email': self.username,
                'password': self.password
            })
        except ClientError as error:
            json_response = error.response.json()
            error_list = json_response.get('errors', {}).get('email', [])
            error_message = error_list[0] if error_list else None
            raise BrowserIncorrectPassword(error_message)

        self.session.headers[
            'Authorization'] = 'Token token="%s"' % self.page.get_token()
Beispiel #15
0
    def do_login(self):
        assert isinstance(self.username, basestring)
        assert isinstance(self.password, basestring)
        assert self.password.isdigit()

        # we force the browser to go to login page so it's work even
        # if the session expire
        self.login.go()

        if not self.page.login(self.username, self.password) or \
           (self.login.is_here() and self.page.is_error()) :
            raise BrowserIncorrectPassword("invalid login/password.\nIf you did not change anything, be sure to check for password renewal request\non the original web site.\nAutomatic renewal will be implemented later.")

        self.accounts.stay_or_go()
Beispiel #16
0
    def do_login(self):
        self.logger.debug('call Browser.do_login')
        if self.logged:
            return True

        self.loginp.stay_or_go()
        if self.homep.is_here():
            self.logged = True
            return True

        self.page.login(self.username, self.password)

        error = self.page.is_error()
        if error:
            raise BrowserIncorrectPassword(error)

        self.homep.stay_or_go(
        )  # Redirection not interpreted by browser. Mannually redirect on homep

        if not self.homep.is_here():
            raise BrowserIncorrectPassword()

        self.logged = True
Beispiel #17
0
    def do_login(self):
        self.login.go('/openam/json/authenticate', method='POST')
        login_data = self.page.get_data(self.username, self.password)
        try:
            self.login.go(json=login_data)
        except ClientError as e:
            raise BrowserIncorrectPassword(e.response.json()['message'])

        self.session.cookies['ICESSOsession'] = self.page.doc['tokenId']
        self.location(self.absurl('/rest/aiguillagemp/redirect'), allow_redirects=True)

        if self.auth.is_here() and self.page.response.status_code != 303:
            raise BrowserIncorrectPassword()

        if self.error.is_here():
            raise BrowserUnavailable(self.page.get_message())

        if 'collectivites' in self.url:
            self.logger.warning('entreprises-collectivites website')
            raise SiteSwitch('collectivites')

        self.session.headers['Content-Type'] = 'application/json;charset=UTF-8'
        self.session.headers['X-XSRF-TOKEN'] = self.session.cookies['XSRF-TOKEN']
Beispiel #18
0
    def login(self, username, password):
        try:
            self.browser.login_result.open(data = {
                "email": username,
                "password": password,
                "remember": "false"
            })
        except ClientError as e:
            if e.response.status_code == 403:
                raise BrowserIncorrectPassword()
            else:
                raise

        self.logged = True
Beispiel #19
0
    def do_login(self):
        self.connected.go()
        if self.not_connected.is_here():
            if self.config['captcha_response'].get() is not None:
                self.login.go(
                    data={
                        'login':
                        self.username,
                        'password':
                        self.password,
                        'rememberMe':
                        "false",
                        'goto':
                        None,
                        'gRecaptchaAuthentResponse':
                        self.config['captcha_response'].get()
                    })
                self.connected.go()

                if self.not_connected.is_here():
                    raise BrowserIncorrectPassword()
                else:
                    return

            self.home.go()

            if self.page.has_captcha_request():
                website_key = self.page.get_recaptcha_key(
                )  # google recaptcha plubic key
                website_url = "https://particulier.edf.fr/fr/accueil.html"
                raise CaptchaQuestion('g_recaptcha',
                                      website_key=website_key,
                                      website_url=website_url)
            else:
                raise BrowserIncorrectPassword()
        else:
            return
Beispiel #20
0
    def on_load(self):
        if self.url.startswith('https://mabanqueprivee.'):
            self.browser.switch('mabanqueprivee')

        # Some kind of internal server error instead of normal wrongpass errorCode.
        if self.get('errorCode') == 'INTO_FACADE ERROR: JDF_GENERIC_EXCEPTION':
            raise BrowserIncorrectPassword()

        error = cast(self.get('errorCode'), int, 0)
        # you can find api documentation on errors here : https://mabanque.bnpparibas/rsc/contrib/document/properties/identification-fr-part-V1.json
        if error:
            error_page = self.browser.list_error_page.open()
            msg = error_page.get_error_message(error)
            if not msg:
                msg = self.get('message')

            wrongpass_codes = [201, 21510, 203, 202, 7]
            actionNeeded_codes = [21501, 3, 4, 50]
            websiteUnavailable_codes = [207, 1001]
            if error in wrongpass_codes:
                raise BrowserIncorrectPassword(msg)
            elif error == 21:  # "Ce service est momentanément indisponible. Veuillez renouveler votre demande ultérieurement." -> In reality, account is blocked because of too much wrongpass
                raise ActionNeeded(u"Compte bloqué")
            elif error in actionNeeded_codes:
                raise ActionNeeded(msg)
            elif error in websiteUnavailable_codes:
                raise BrowserUnavailable(msg)
            else:
                assert False, 'Unexpected error at login: "******" (code=%s)' % (
                    msg, error)

        parser = html.HTMLParser(encoding=self.encoding)
        doc = html.parse(BytesIO(self.content), parser)
        error = CleanText(
            '//div[h1[contains(text(), "Incident en cours")]]/p')(doc)
        if error:
            raise BrowserUnavailable(error)
Beispiel #21
0
    def handle_login_error(self, r):
        error_page = r.response.json()
        assert 'error' in error_page, "Something went wrong in login"
        error = error_page['error']

        if error['code'] in (
                'AUTHENTICATION.INVALID_PIN_CODE',
                'AUTHENTICATION.INVALID_CIF_AND_BIRTHDATE_COMBINATION'):
            raise BrowserIncorrectPassword(error['message'])
        elif error['code'] in ('AUTHENTICATION.ACCOUNT_INACTIVE',
                               'AUTHENTICATION.ACCOUNT_LOCKED',
                               'AUTHENTICATION.NO_COMPLETE_ACCOUNT_FOUND'):
            raise ActionNeeded(error['message'])
        assert error['code'] != 'INPUT_INVALID', error['message']
        raise BrowserUnavailable(error['message'])
Beispiel #22
0
 def do_login(self):
     self.login_page.go()
     self.page.login(self.username, self.password)
     if self.term_page.is_here():
         raise ActionNeeded()
     if self.error_page.is_here() or self.error_page2.is_here():
         alert = self.page.get_error()
         if "account has not been activated" in alert:
             raise ActionNeeded(alert)
         elif "unexpected" in alert:
             raise BrowserUnavailable(alert)
         elif "password" in alert:
             raise BrowserIncorrectPassword(alert)
         else:
             assert False
Beispiel #23
0
    def do_login(self):
        self.logger.debug('call Browser.do_login')

        # set this cookie to get login form in response
        self.session.cookies['hbc'] = ''
        self.loginp.stay_or_go()
        if self.homep.is_here():
            return True

        self.page.login(self.username, self.password)

        error = self.page.is_error()
        if error:
            raise BrowserIncorrectPassword(error)

        self.page.locate_to_cgu_page()
        if self.cgup.is_here():
            raise ActionNeeded(self.page.get_cgu())

        self.homep.stay_or_go(
        )  # Redirection not interpreted by browser. Manually redirect on homep

        if not self.homep.is_here():
            raise BrowserIncorrectPassword()
Beispiel #24
0
    def request_access_token(self, auth_uri):
        self.logger.info('requesting access token')

        if isinstance(auth_uri, dict):
            values = auth_uri
        else:
            values = dict(parse_qsl(urlparse(auth_uri).query))
        self.handle_callback_error(values)
        data = self.build_access_token_parameters(values)
        try:
            auth_response = self.do_token_request(data).json()
        except ClientError:
            raise BrowserIncorrectPassword()

        self.update_token(auth_response)
Beispiel #25
0
    def do_login(self):
        self.login_page.go()

        try:
            self.page.login(self.username, self.password, self.lastname)
        except ClientError as e:
            if e.response.status_code == 401:
                raise BrowserIncorrectPassword()
            raise

        if self.login_page.is_here():
            msg = self.page.get_error_message()
            raise BrowserIncorrectPassword(msg)

        if self.forgotten_password_page.is_here():
            # when too much attempt has been done in a short time, bouygues redirect us here,
            # but no message is available on this page
            raise BrowserIncorrectPassword()

        # q is timestamp millisecond
        self.app_config.go(params={'q': int(time() * 1000)})
        client_id = self.page.get_client_id()

        params = {
            'client_id': client_id,
            'response_type': 'id_token token',
            'redirect_uri': 'https://www.bouyguestelecom.fr/mon-compte/'
        }
        self.location('https://oauth2.bouyguestelecom.fr/authorize',
                      params=params)
        fragments = dict(parse_qsl(urlparse(self.url).fragment))

        self.id_personne = jwt.get_unverified_claims(
            fragments['id_token'])['id_personne']
        authorization = 'Bearer ' + fragments['access_token']
        self.headers = {'Authorization': authorization}
Beispiel #26
0
    def do_login(self):
        self.logger.debug('call Browser.do_login')
        if self.logged:
            return True

        self.loginp.stay_or_go()
        self.loginvalidity.go(data={
            "identifiant": self.username,
            "secret": self.password
        })
        if not self.page.check_logged():
            raise BrowserIncorrectPassword()
        self.authp.go(data={"": ""})
        self.token = self.page.get_xsrf()
        self.logged = True
Beispiel #27
0
    def do_login(self):
        self.location(self.BASEURL)
        # avoids trying to relog in while it's already on home page
        if self.home_page.is_here():
            return

        self.is_password_only_digits = self.password.isdigit()

        self.page.login(self.username, self.password)
        if self.login_page.is_here():
            raise BrowserIncorrectPassword()
        if 'internetRescuePortal' in self.url:
            # 1 more request is necessary
            data = {'integrationMode': 'INTERNET_RESCUE'}
            self.location('/cyber/internet/Login.do', data=data)
Beispiel #28
0
    def do_login(self):
        self.logger.debug('call Browser.do_login')
        if self.logged:
            return True

        self.loginp.stay_or_go()
        self.loginvalidity.go(data={
            "identifiant": self.username,
            "secret": self.password
        })
        if not self.page.check_logged():
            raise BrowserIncorrectPassword()
        self.authp.go(data="{}", headers={'Content-Type': 'application/json'})
        self.token = self.page.get_xsrf()
        self.logged = True
Beispiel #29
0
    def on_load(self):
        if self.url.startswith('https://mabanqueprivee.'):
            self.browser.switch('mabanqueprivee')

        # Some kind of internal server error instead of normal wrongpass errorCode.
        if self.get('errorCode') == 'INTO_FACADE ERROR: JDF_GENERIC_EXCEPTION':
            raise BrowserIncorrectPassword()

        error = cast(self.get('errorCode'), int, 0)

        if error:
            codes = [201, 21510, 203, 202]
            msg = self.get('message')
            if error in codes:
                raise BrowserIncorrectPassword(msg)
            elif error == 1001:
                # json says "Erreur lors de l'authentification Code retour : 1001 Code retour : 1001"
                # but js message from "getErrorMessage" says "veuillez contacter votre conseiller"...
                raise BrowserIncorrectPassword()
            elif error == 21501:  # "Rendez-vous sur le site de BNP Paribas pour gérer vos comptes"
                raise ActionNeeded(msg)

            self.logger.debug('Unexpected error at login: "******" (code=%s)' %
                              (msg, error))
Beispiel #30
0
    def do_login(self):
        self.session.cookies.clear()

        self.login.go()

        self.page.login(self.username, self.password)

        if self.choice.is_here():
            self.has_other = self.has_oney = True
        elif self.credit_home.is_here():
            self.has_other = True
        elif self.client.is_here():
            self.has_oney = True
        else:
            raise BrowserIncorrectPassword()