mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 19:14:54 +02:00
Revert "Add cmd line arg for the authenticator"
This reverts commit 5d2abc30f0.
This commit is contained in:
@@ -349,29 +349,13 @@ def init_csr(privkey, names, cert_dir):
|
|||||||
return le_util.CSR(csr_filename, csr_der, "der")
|
return le_util.CSR(csr_filename, csr_der, "der")
|
||||||
|
|
||||||
|
|
||||||
def list_available_authenticators(avail_auths):
|
|
||||||
"""Return a pretty-printed list of authenticators.
|
|
||||||
|
|
||||||
This is used to provide helpful feedback in the case where a user
|
|
||||||
specifies an invalid authenticator on the command line.
|
|
||||||
|
|
||||||
"""
|
|
||||||
output_lines = ["Available authenticators:"]
|
|
||||||
for auth_name, auth in avail_auths.iteritems():
|
|
||||||
output_lines.append(" - %s : %s" % (auth_name, auth.description))
|
|
||||||
return '\n'.join(output_lines)
|
|
||||||
|
|
||||||
|
|
||||||
# This should be controlled by commandline parameters
|
# This should be controlled by commandline parameters
|
||||||
def determine_authenticator(all_auths, config):
|
def determine_authenticator(all_auths):
|
||||||
"""Returns a valid IAuthenticator.
|
"""Returns a valid IAuthenticator.
|
||||||
|
|
||||||
:param list all_auths: Where each is a
|
:param list all_auths: Where each is a
|
||||||
:class:`letsencrypt.client.interfaces.IAuthenticator` object
|
:class:`letsencrypt.client.interfaces.IAuthenticator` object
|
||||||
|
|
||||||
:param config: Used if an authenticator was specified on the command line.
|
|
||||||
:type config: :class:`letsencrypt.client.interfaces.IConfig`
|
|
||||||
|
|
||||||
:returns: Valid Authenticator object or None
|
:returns: Valid Authenticator object or None
|
||||||
|
|
||||||
:raises letsencrypt.client.errors.LetsEncryptClientError: If no
|
:raises letsencrypt.client.errors.LetsEncryptClientError: If no
|
||||||
@@ -379,33 +363,23 @@ def determine_authenticator(all_auths, config):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
# Available Authenticator objects
|
# Available Authenticator objects
|
||||||
avail_auths = {}
|
avail_auths = []
|
||||||
# Error messages for misconfigured authenticators
|
# Error messages for misconfigured authenticators
|
||||||
errs = {}
|
errs = {}
|
||||||
|
|
||||||
for auth_name, auth in all_auths.iteritems():
|
for pot_auth in all_auths:
|
||||||
try:
|
try:
|
||||||
auth.prepare()
|
pot_auth.prepare()
|
||||||
except errors.LetsEncryptMisconfigurationError as err:
|
except errors.LetsEncryptMisconfigurationError as err:
|
||||||
errs[auth] = err
|
errs[pot_auth] = err
|
||||||
except errors.LetsEncryptNoInstallationError:
|
except errors.LetsEncryptNoInstallationError:
|
||||||
continue
|
continue
|
||||||
avail_auths[auth_name] = auth
|
avail_auths.append(pot_auth)
|
||||||
|
|
||||||
# If an authenticator was specified on the command line, try to use it
|
if len(avail_auths) > 1:
|
||||||
if config.authenticator:
|
auth = display_ops.choose_authenticator(avail_auths, errs)
|
||||||
try:
|
elif len(avail_auths) == 1:
|
||||||
auth = avail_auths[config.authenticator]
|
auth = avail_auths[0]
|
||||||
except KeyError:
|
|
||||||
logging.error(
|
|
||||||
"The specified authenticator '%s' could not be found",
|
|
||||||
config.authenticator)
|
|
||||||
logging.info(list_available_authenticators(avail_auths))
|
|
||||||
return
|
|
||||||
elif len(avail_auths) > 1:
|
|
||||||
auth = display_ops.choose_authenticator(avail_auths.values(), errs)
|
|
||||||
elif len(avail_auths.keys()) == 1:
|
|
||||||
auth = avail_auths[avail_auths.keys()[0]]
|
|
||||||
else:
|
else:
|
||||||
raise errors.LetsEncryptClientError("No Authenticators available.")
|
raise errors.LetsEncryptClientError("No Authenticators available.")
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ class IAuthenticator(zope.interface.Interface):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
description = zope.interface.Attribute(
|
|
||||||
"Short description of this authenticator. "
|
|
||||||
"Used in interactive configuration.")
|
|
||||||
|
|
||||||
def prepare():
|
def prepare():
|
||||||
"""Prepare the authenticator.
|
"""Prepare the authenticator.
|
||||||
|
|
||||||
@@ -93,8 +89,6 @@ class IConfig(zope.interface.Interface):
|
|||||||
server = zope.interface.Attribute(
|
server = zope.interface.Attribute(
|
||||||
"CA hostname (and optionally :port). The server certificate must "
|
"CA hostname (and optionally :port). The server certificate must "
|
||||||
"be trusted in order to avoid further modifications to the client.")
|
"be trusted in order to avoid further modifications to the client.")
|
||||||
authenticator = zope.interface.Attribute(
|
|
||||||
"Authenticator to use for responding to challenges.")
|
|
||||||
rsa_key_size = zope.interface.Attribute("Size of the RSA key.")
|
rsa_key_size = zope.interface.Attribute("Size of the RSA key.")
|
||||||
|
|
||||||
config_dir = zope.interface.Attribute("Configuration directory.")
|
config_dir = zope.interface.Attribute("Configuration directory.")
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ SETUPTOOLS_AUTHENTICATORS_ENTRY_POINT = "letsencrypt.authenticators"
|
|||||||
|
|
||||||
def init_auths(config):
|
def init_auths(config):
|
||||||
"""Find (setuptools entry points) and initialize Authenticators."""
|
"""Find (setuptools entry points) and initialize Authenticators."""
|
||||||
# TODO: handle collisions in authenticator names. Or is this
|
|
||||||
# already handled for us by pkg_resources?
|
|
||||||
auths = {}
|
auths = {}
|
||||||
for entrypoint in pkg_resources.iter_entry_points(
|
for entrypoint in pkg_resources.iter_entry_points(
|
||||||
SETUPTOOLS_AUTHENTICATORS_ENTRY_POINT):
|
SETUPTOOLS_AUTHENTICATORS_ENTRY_POINT):
|
||||||
@@ -46,7 +44,7 @@ def init_auths(config):
|
|||||||
"%r object does not provide IAuthenticator, skipping",
|
"%r object does not provide IAuthenticator, skipping",
|
||||||
entrypoint.name)
|
entrypoint.name)
|
||||||
else:
|
else:
|
||||||
auths[entrypoint.name] = auth
|
auths[auth] = entrypoint.name
|
||||||
return auths
|
return auths
|
||||||
|
|
||||||
|
|
||||||
@@ -62,12 +60,6 @@ def create_parser():
|
|||||||
add("-s", "--server", default="letsencrypt-demo.org:443",
|
add("-s", "--server", default="letsencrypt-demo.org:443",
|
||||||
help=config_help("server"))
|
help=config_help("server"))
|
||||||
|
|
||||||
# TODO: we should generate the list of choices from the set of
|
|
||||||
# available authenticators, but that is tricky due to the
|
|
||||||
# dependency between init_auths and config. Hardcoding it for now.
|
|
||||||
add("-a", "--authenticator", dest="authenticator",
|
|
||||||
help=config_help("authenticator"))
|
|
||||||
|
|
||||||
add("-k", "--authkey", type=read_file,
|
add("-k", "--authkey", type=read_file,
|
||||||
help="Path to the authorized key file")
|
help="Path to the authorized key file")
|
||||||
add("-B", "--rsa-key-size", type=int, default=2048, metavar="N",
|
add("-B", "--rsa-key-size", type=int, default=2048, metavar="N",
|
||||||
@@ -174,10 +166,9 @@ def main(): # pylint: disable=too-many-branches, too-many-statements
|
|||||||
display_eula()
|
display_eula()
|
||||||
|
|
||||||
all_auths = init_auths(config)
|
all_auths = init_auths(config)
|
||||||
logging.debug('Initialized authenticators: %s', all_auths.keys())
|
logging.debug('Initialized authenticators: %s', all_auths.values())
|
||||||
try:
|
try:
|
||||||
auth = client.determine_authenticator(all_auths, config)
|
auth = client.determine_authenticator(all_auths.keys())
|
||||||
logging.debug("Selected authenticator: %s", auth)
|
|
||||||
except errors.LetsEncryptClientError:
|
except errors.LetsEncryptClientError:
|
||||||
logging.critical("No authentication mechanisms were found on your "
|
logging.critical("No authentication mechanisms were found on your "
|
||||||
"system.")
|
"system.")
|
||||||
|
|||||||
Reference in New Issue
Block a user