mirror of
https://github.com/certbot/certbot.git
synced 2026-06-08 00:02:14 -04:00
Move init_auths to scripts/main.py.
This commit is contained in:
parent
d9871b59f0
commit
8e32ae8246
2 changed files with 25 additions and 28 deletions
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Reference in a new issue