1
0
mirror of https://github.com/laurivosandi/certidude synced 2024-12-23 00:25:18 +00:00

api: bootstrap: drop usage of global authority import

This commit is contained in:
Priit Laes 2018-02-03 12:39:49 +02:00
parent 863deafa59
commit 937c81bd5f
2 changed files with 8 additions and 5 deletions

View File

@ -9,7 +9,7 @@ import hashlib
from datetime import datetime, timedelta from datetime import datetime, timedelta
from time import sleep from time import sleep
from xattr import listxattr, getxattr from xattr import listxattr, getxattr
from certidude import authority, mailer from certidude import mailer
from certidude.auth import login_required, authorize_admin from certidude.auth import login_required, authorize_admin
from certidude.user import User from certidude.user import User
from certidude.decorators import serialize, csrf_protection from certidude.decorators import serialize, csrf_protection
@ -202,7 +202,7 @@ class NormalizeMiddleware(object):
req.context["remote_addr"] = ipaddress.ip_address(req.access_route[0]) req.context["remote_addr"] = ipaddress.ip_address(req.access_route[0])
def certidude_app(log_handlers=[]): def certidude_app(log_handlers=[]):
from certidude import config from certidude import authority, config
from .signed import SignedCertificateDetailResource from .signed import SignedCertificateDetailResource
from .request import RequestListResource, RequestDetailResource from .request import RequestListResource, RequestDetailResource
from .lease import LeaseResource, LeaseDetailResource from .lease import LeaseResource, LeaseDetailResource
@ -242,7 +242,7 @@ def certidude_app(log_handlers=[]):
app.add_route("/api/lease/", LeaseResource()) app.add_route("/api/lease/", LeaseResource())
# Bootstrap resource # Bootstrap resource
app.add_route("/api/bootstrap/", BootstrapResource()) app.add_route("/api/bootstrap/", BootstrapResource(authority))
# LEDE image builder resource # LEDE image builder resource
app.add_route("/api/build/{profile}/{suggested_filename}", ImageBuilderResource()) app.add_route("/api/build/{profile}/{suggested_filename}", ImageBuilderResource())

View File

@ -1,14 +1,17 @@
import logging import logging
from certidude.decorators import serialize from certidude.decorators import serialize
from certidude.config import cp from certidude.config import cp
from certidude import authority, config, const from certidude import config, const
from jinja2 import Template from jinja2 import Template
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class BootstrapResource(object): class BootstrapResource(object):
def __init__(self, authority):
self.authority = authority
def on_get(self, req, resp): def on_get(self, req, resp):
resp.body = Template(open(config.BOOTSTRAP_TEMPLATE).read()).render( resp.body = Template(open(config.BOOTSTRAP_TEMPLATE).read()).render(
authority = const.FQDN, authority = const.FQDN,
servers = authority.list_server_names()) servers = self.authority.list_server_names())