def enhance_config(self, domains, redirect=None): """Enhance the configuration. .. todo:: This needs to handle the specific enhancements offered by the installer. We will also have to find a method to pass in the chosen values efficiently. :param list domains: list of domains to configure :param redirect: If traffic should be forwarded from HTTP to HTTPS. :type redirect: bool or None :raises .errors.Error: if no installer is specified in the client. """ if self.installer is None: logger.warning("No installer is specified, there isn't any " "configuration to enhance.") raise errors.Error("No installer available") if redirect is None: redirect = enhancements.ask("redirect") if redirect: self.redirect_to_ssl(domains)
def enhance_config(self, domains, redirect=None): """Enhance the configuration. .. todo:: This needs to handle the specific enhancements offered by the installer. We will also have to find a method to pass in the chosen values efficiently. :param list domains: list of domains to configure :param redirect: If traffic should be forwarded from HTTP to HTTPS. :type redirect: bool or None :raises .errors.Error: if no installer is specified in the client. """ if self.installer is None: logger.warning("No installer is specified, there isn't any " "configuration to enhance.") raise errors.Error("No installer available") if redirect is None: redirect = enhancements.ask("redirect") # When support for more enhancements are added, the call to the # plugin's `enhance` function should be wrapped by an ErrorHandler if redirect: self.redirect_to_ssl(domains)
def enhance_config(self, domains, redirect=None): """Enhance the configuration. .. todo:: This needs to handle the specific enhancements offered by the installer. We will also have to find a method to pass in the chosen values efficiently. :param list domains: list of domains to configure :param redirect: If traffic should be forwarded from HTTP to HTTPS. :type redirect: bool or None :raises letsencrypt.errors.LetsEncryptClientError: if no installer is specified in the client. """ if self.installer is None: logging.warning("No installer is specified, there isn't any " "configuration to enhance.") raise errors.LetsEncryptClientError("No installer available") if redirect is None: redirect = enhancements.ask("redirect") if redirect: self.redirect_to_ssl(domains)
def enhance_config(self, domains, config): """Enhance the configuration. :param list domains: list of domains to configure :ivar config: Namespace typically produced by :meth:`argparse.ArgumentParser.parse_args`. it must have the redirect, hsts and uir attributes. :type namespace: :class:`argparse.Namespace` :raises .errors.Error: if no installer is specified in the client. """ if self.installer is None: logger.warning("No installer is specified, there isn't any " "configuration to enhance.") raise errors.Error("No installer available") if config is None: logger.warning("No config is specified.") raise errors.Error("No config available") supported = self.installer.supported_enhancements() redirect = config.redirect if "redirect" in supported else False hsts = config.hsts if "ensure-http-header" in supported else False uir = config.uir if "ensure-http-header" in supported else False if redirect is None: redirect = enhancements.ask("redirect") if redirect: self.apply_enhancement(domains, "redirect") if hsts: self.apply_enhancement(domains, "ensure-http-header", "Strict-Transport-Security") if uir: self.apply_enhancement(domains, "ensure-http-header", "Upgrade-Insecure-Requests") msg = ("We were unable to restart web server") if redirect or hsts or uir: with error_handler.ErrorHandler(self._rollback_and_restart, msg): self.installer.restart()
def _call(cls, enhancement): from letsencrypt.display.enhancements import ask return ask(enhancement)