From c28a94529571adcaef6ed3cc01b4e17f46cd0c7d Mon Sep 17 00:00:00 2001 From: James Kasten Date: Thu, 12 Feb 2015 01:06:30 -0800 Subject: [PATCH] Clarify authenticator interface --- letsencrypt/client/auth_handler.py | 16 +++++++++++----- letsencrypt/client/interfaces.py | 21 ++++++++++----------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/letsencrypt/client/auth_handler.py b/letsencrypt/client/auth_handler.py index 6f0ece535..ee69898c6 100644 --- a/letsencrypt/client/auth_handler.py +++ b/letsencrypt/client/auth_handler.py @@ -151,8 +151,10 @@ class AuthHandler(object): # pylint: disable=too-many-instance-attributes flat_auth.extend(ichall.chall for ichall in self.dv_c[dom]) try: - client_resp = self.client_auth.perform(flat_client) - dv_resp = self.dv_auth.perform(flat_auth) + if flat_client: + client_resp = self.client_auth.perform(flat_client) + if flat_auth: + dv_resp = self.dv_auth.perform(flat_auth) # This will catch both specific types of errors. except errors.LetsEncryptAuthHandlerError as err: logging.critical("Failure in setting up challenges:") @@ -212,9 +214,13 @@ class AuthHandler(object): # pylint: disable=too-many-instance-attributes # These are indexed challenges... give just the challenges to the auth # Chose to make these lists instead of a generator to make it easier to # work with... - self.dv_auth.cleanup([ichall.chall for ichall in self.dv_c[domain]]) - self.client_auth.cleanup( - [ichall.chall for ichall in self.client_c[domain]]) + dv_list = [ichall.chall for ichall in self.dv_c[domain]] + client_list = [ichall.chall for ichall in self.client_c[domain]] + if dv_list: + self.dv_auth.cleanup(dv_list) + if client_list: + self.client_auth.cleanup(client_list) + def _cleanup_state(self, delete_list): """Cleanup state after an authorization is received. diff --git a/letsencrypt/client/interfaces.py b/letsencrypt/client/interfaces.py index 9fcd95c6a..04c7d35e7 100644 --- a/letsencrypt/client/interfaces.py +++ b/letsencrypt/client/interfaces.py @@ -30,6 +30,9 @@ class IAuthenticator(zope.interface.Interface): :param list chall_list: List of namedtuple types defined in :mod:`letsencrypt.client.challenge_util` (``DvsniChall``, etc.). + - chall_list will never be empty + - chall_list will only contain types found within + :func:`get_chall_pref` :returns: ACME Challenge responses or if it cannot be completed then: @@ -43,20 +46,16 @@ class IAuthenticator(zope.interface.Interface): """ def cleanup(chall_list): - """Revert changes and shutdown after challenges complete.""" + """Revert changes and shutdown after challenges complete. + :param list chall_list: List of namedtuple types defined in + :mod:`letsencrypt.client.challenge_util` (``DvsniChall``, etc.) -class IChallenge(zope.interface.Interface): - """Let's Encrypt challenge.""" + - Only challenges given previously in the perform function will be + found in chall_list. + - chall_list will never be empty - def perform(): - """Perform the challenge.""" - - def generate_response(): - """Generate response.""" - - def cleanup(): - """Cleanup.""" + """ class IConfig(zope.interface.Interface):