def on_authentication_required(self, reply, authenticator): """Called when a website needs authentication.""" user, password = None, None if not hasattr(reply, "netrc_used") and 'HOME' in os.environ: # We'll get an OSError by netrc if 'HOME' isn't available in # os.environ. We don't want to log that, so we prevent it # altogether. reply.netrc_used = True try: net = netrc.netrc(config.get('network', 'netrc-file')) authenticators = net.authenticators(reply.url().host()) if authenticators is not None: (user, _account, password) = authenticators except FileNotFoundError: log.misc.debug("No .netrc file found") except OSError: log.misc.exception("Unable to read the netrc file") except netrc.NetrcParseError: log.misc.exception("Error when parsing the netrc file") if user is not None: authenticator.setUser(user) authenticator.setPassword(password) else: abort_on = self._get_abort_signals(reply) shared.authentication_required(reply.url(), authenticator, abort_on=abort_on)
def on_authentication_required(self, reply, authenticator): """Called when a website needs authentication.""" netrc_success = False if not self.netrc_used: self.netrc_used = True netrc_success = shared.netrc_authentication( reply.url(), authenticator) if not netrc_success: abort_on = self._get_abort_signals(reply) shared.authentication_required(reply.url(), authenticator, abort_on=abort_on)
def on_authentication_required(self, reply, authenticator): """Called when a website needs authentication.""" url = reply.url() log.network.debug("Authentication requested for {}, netrc_used {}" .format(url.toDisplayString(), self.netrc_used)) netrc_success = False if not self.netrc_used: self.netrc_used = True netrc_success = shared.netrc_authentication(url, authenticator) if not netrc_success: log.network.debug("Asking for credentials") abort_on = self._get_abort_signals(reply) shared.authentication_required(url, authenticator, abort_on=abort_on)
def _on_authentication_required(self, url, authenticator): # FIXME:qtwebengine support .netrc answer = shared.authentication_required( url, authenticator, abort_on=[self.shutting_down, self.load_started]) if answer is None: # WORKAROUND for # https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html url_string = url.toDisplayString() error_page = jinja.render( 'error.html', title="Error loading page: {}".format(url_string), url=url_string, error="Authentication required", icon='') self.set_html(error_page)
def _on_authentication_required(self, url, authenticator): netrc_success = False if not self.data.netrc_used: self.data.netrc_used = True netrc_success = shared.netrc_authentication(url, authenticator) if not netrc_success: abort_on = [self.shutting_down, self.load_started] answer = shared.authentication_required(url, authenticator, abort_on) if not netrc_success and answer is None: try: # pylint: disable=no-member, useless-suppression sip.assign(authenticator, QAuthenticator()) # pylint: enable=no-member, useless-suppression except AttributeError: # WORKAROUND for # https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html self._show_error_page(url, "Authentication required")
def _on_authentication_required(self, url, authenticator): # FIXME:qtwebengine support .netrc answer = shared.authentication_required( url, authenticator, abort_on=[self.shutting_down, self.load_started]) if answer is None: try: # pylint: disable=no-member, useless-suppression sip.assign(authenticator, QAuthenticator()) except AttributeError: # WORKAROUND for # https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html url_string = url.toDisplayString() error_page = jinja.render( 'error.html', title="Error loading page: {}".format(url_string), url=url_string, error="Authentication required") self.set_html(error_page)
def _on_authentication_required(self, url, authenticator): # FIXME:qtwebengine support .netrc answer = shared.authentication_required( url, authenticator, abort_on=[self.shutting_down, self.load_started]) if answer is None: try: # pylint: disable=no-member, useless-suppression sip.assign(authenticator, QAuthenticator()) # pylint: enable=no-member, useless-suppression except AttributeError: # WORKAROUND for # https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html url_string = url.toDisplayString() error_page = jinja.render( 'error.html', title="Error loading page: {}".format(url_string), url=url_string, error="Authentication required") self.set_html(error_page)
def _on_authentication_required(self, url, authenticator): netrc_success = False if not self.data.netrc_used: self.data.netrc_used = True netrc_success = shared.netrc_authentication(url, authenticator) if not netrc_success: abort_on = [self.shutting_down, self.load_started] answer = shared.authentication_required(url, authenticator, abort_on) if not netrc_success and answer is None: try: # pylint: disable=no-member, useless-suppression sip.assign(authenticator, QAuthenticator()) # pylint: enable=no-member, useless-suppression except AttributeError: # WORKAROUND for # https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html url_string = url.toDisplayString() error_page = jinja.render( 'error.html', title="Error loading page: {}".format(url_string), url=url_string, error="Authentication required") self.set_html(error_page)
def _on_authentication_required(self, url, authenticator): # FIXME:qtwebengine support .netrc shared.authentication_required( url, authenticator, abort_on=[self.shutting_down, self.load_started])
def _on_authentication_required(self, url, authenticator): # FIXME:qtwebengine support .netrc shared.authentication_required(url, authenticator, abort_on=[self.shutting_down, self.load_started])