From 8e32ae82467a0d2597eb835a3ed8a1d5546e72ad Mon Sep 17 00:00:00 2001 From: Jakub Warmuz Date: Thu, 26 Mar 2015 22:00:00 +0000 Subject: [PATCH 1/5] Move init_auths to scripts/main.py. --- letsencrypt/client/client.py | 27 --------------------------- letsencrypt/scripts/main.py | 26 +++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/letsencrypt/client/client.py b/letsencrypt/client/client.py index 01f5e1c80..2f3f9a769 100644 --- a/letsencrypt/client/client.py +++ b/letsencrypt/client/client.py @@ -1,15 +1,11 @@ """ACME protocol client class and helper functions.""" import logging import os -import pkg_resources import sys import Crypto.PublicKey.RSA import M2Crypto -import zope.interface.exceptions -import zope.interface.verify - from letsencrypt.acme import messages from letsencrypt.acme.jose import util as jose_util @@ -17,7 +13,6 @@ from letsencrypt.client import auth_handler from letsencrypt.client import client_authenticator from letsencrypt.client import crypto_util from letsencrypt.client import errors -from letsencrypt.client import interfaces from letsencrypt.client import le_util from letsencrypt.client import network from letsencrypt.client import reverter @@ -28,28 +23,6 @@ from letsencrypt.client.display import ops as display_ops from letsencrypt.client.display import enhancements -SETUPTOOLS_AUTHENTICATORS_ENTRY_POINT = "letsencrypt.authenticators" -"""Setuptools entry point group name for Authenticator plugins.""" - - -def init_auths(config): - """Find (setuptools entry points) and initialize Authenticators.""" - auths = {} - for entrypoint in pkg_resources.iter_entry_points( - SETUPTOOLS_AUTHENTICATORS_ENTRY_POINT): - auth_cls = entrypoint.load() - auth = auth_cls(config) - try: - zope.interface.verify.verifyObject(interfaces.IAuthenticator, auth) - except zope.interface.exceptions.BrokenImplementation: - logging.debug( - "%r object does not provide IAuthenticator, skipping", - entrypoint.name) - else: - auths[auth] = entrypoint.name - return auths - - class Client(object): """ACME protocol client. diff --git a/letsencrypt/scripts/main.py b/letsencrypt/scripts/main.py index 8b2c62935..3b4b7c10d 100644 --- a/letsencrypt/scripts/main.py +++ b/letsencrypt/scripts/main.py @@ -11,6 +11,8 @@ import sys import confargparse import zope.component +import zope.interface.exceptions +import zope.interface.verify import letsencrypt @@ -24,6 +26,28 @@ from letsencrypt.client.display import util as display_util from letsencrypt.client.display import ops as display_ops +SETUPTOOLS_AUTHENTICATORS_ENTRY_POINT = "letsencrypt.authenticators" +"""Setuptools entry point group name for Authenticator plugins.""" + + +def init_auths(config): + """Find (setuptools entry points) and initialize Authenticators.""" + auths = {} + for entrypoint in pkg_resources.iter_entry_points( + SETUPTOOLS_AUTHENTICATORS_ENTRY_POINT): + auth_cls = entrypoint.load() + auth = auth_cls(config) + try: + zope.interface.verify.verifyObject(interfaces.IAuthenticator, auth) + except zope.interface.exceptions.BrokenImplementation: + logging.debug( + "%r object does not provide IAuthenticator, skipping", + entrypoint.name) + else: + auths[auth] = entrypoint.name + return auths + + def create_parser(): """Create parser.""" parser = confargparse.ConfArgParser( @@ -134,7 +158,7 @@ def main(): # pylint: disable=too-many-branches, too-many-statements if not args.eula: display_eula() - all_auths = client.init_auths(config) + all_auths = init_auths(config) logging.debug('Initialized authenticators: %s', all_auths.values()) try: auth = client.determine_authenticator(all_auths.keys()) From 6b78789ea3963ba406538d733f9ff65db8337fa7 Mon Sep 17 00:00:00 2001 From: Jakub Warmuz Date: Thu, 26 Mar 2015 22:12:40 +0000 Subject: [PATCH 2/5] Improve plugins.rst --- docs/plugins.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/plugins.rst b/docs/plugins.rst index 552985aab..fafb8d5d3 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -2,4 +2,12 @@ Plugins ======= -You can find an example in ``examples/plugins/`` directory. +Let's Encrypt client supports dynamic discovery of plugins through the +`setuptools entry points`_. This way you can, for example, create a +custom implementation of +`~letsencrypt.client.interfaces.IAuthenticator` without having to +merge it with the core upstream source code. Example is provided in +``examples/plugins/`` directory. + +.. _`setuptools entry points`: + https://pythonhosted.org/setuptools/setuptools.html#dynamic-discovery-of-services-and-plugins From 8fa2204afe8b6ee6fe758f51f438495ca17e0659 Mon Sep 17 00:00:00 2001 From: James Kasten Date: Fri, 27 Mar 2015 12:29:27 -0700 Subject: [PATCH 3/5] Add disclaimer in plugins doc --- docs/plugins.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/plugins.rst b/docs/plugins.rst index fafb8d5d3..0451bfe3f 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -5,9 +5,15 @@ Plugins Let's Encrypt client supports dynamic discovery of plugins through the `setuptools entry points`_. This way you can, for example, create a custom implementation of -`~letsencrypt.client.interfaces.IAuthenticator` without having to -merge it with the core upstream source code. Example is provided in +`~letsencrypt.client.interfaces.IAuthenticator` or the +'~letsencrypt.client.interfaces.IInstaller' without having to +merge it with the core upstream source code. An example is provided in ``examples/plugins/`` directory. +Please be aware though that as this client is still in a developer-preview +stage, the API may undergo a few changes. If you believe the plugin will be +beneficial to the community, please consider submitting a pull request to the +repo and we will update it with any necessary API changes. + .. _`setuptools entry points`: https://pythonhosted.org/setuptools/setuptools.html#dynamic-discovery-of-services-and-plugins From 0a1687eed5e8ad79c12399de0a9426be2c0871ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=A4rtner?= Date: Fri, 27 Mar 2015 20:31:29 +0100 Subject: [PATCH 4/5] Fixed wrong linking to CONTRIBUTING --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 86d85ed1d..b65230dc4 100644 --- a/README.rst +++ b/README.rst @@ -80,7 +80,7 @@ Documentation: https://letsencrypt.readthedocs.org/ Software project: https://github.com/letsencrypt/lets-encrypt-preview -Notes for developers: CONTRIBUTING.rst_ +Notes for developers: CONTRIBUTING.md_ Main Website: https://letsencrypt.org/ From 5763da07ff0a88354d131a297801100e9a1db81e Mon Sep 17 00:00:00 2001 From: James Kasten Date: Fri, 27 Mar 2015 12:38:46 -0700 Subject: [PATCH 5/5] Finish contributing.md update Fix relevant links in README --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index b65230dc4..fac36dbd7 100644 --- a/README.rst +++ b/README.rst @@ -91,4 +91,4 @@ email to client-dev+subscribe@letsencrypt.org) .. _Freenode: https://freenode.net .. _client-dev: https://groups.google.com/a/letsencrypt.org/forum/#!forum/client-dev -.. _CONTRIBUTING.rst: https://github.com/letsencrypt/lets-encrypt-preview/blob/master/CONTRIBUTING.rst +.. _CONTRIBUTING.md: https://github.com/letsencrypt/lets-encrypt-preview/blob/master/CONTRIBUTING.md