1
0
mirror of https://github.com/laurivosandi/certidude synced 2024-12-22 16:25:17 +00:00

api: script: drop usage of global authority import

This commit is contained in:
Priit Laes 2018-02-03 12:54:36 +02:00
parent 1cfb1b3293
commit 29f3e1fce9
2 changed files with 6 additions and 3 deletions

View File

@ -229,7 +229,7 @@ def certidude_app(log_handlers=[]):
# Extended attributes for scripting etc. # Extended attributes for scripting etc.
app.add_route("/api/signed/{cn}/attr/", AttributeResource(authority, namespace="machine")) app.add_route("/api/signed/{cn}/attr/", AttributeResource(authority, namespace="machine"))
app.add_route("/api/signed/{cn}/script/", ScriptResource()) app.add_route("/api/signed/{cn}/script/", ScriptResource(authority))
# API calls used by pushed events on the JS end # API calls used by pushed events on the JS end
app.add_route("/api/signed/{cn}/tag/", TagResource()) app.add_route("/api/signed/{cn}/tag/", TagResource())

View File

@ -1,7 +1,7 @@
import falcon import falcon
import logging import logging
import os import os
from certidude import const, config, authority from certidude import const, config
from certidude.decorators import serialize from certidude.decorators import serialize
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
from certidude.firewall import whitelist_subject from certidude.firewall import whitelist_subject
@ -10,9 +10,12 @@ logger = logging.getLogger(__name__)
env = Environment(loader=FileSystemLoader(config.SCRIPT_DIR), trim_blocks=True) env = Environment(loader=FileSystemLoader(config.SCRIPT_DIR), trim_blocks=True)
class ScriptResource(): class ScriptResource():
def __init__(self, authority):
self.authority = authority
@whitelist_subject @whitelist_subject
def on_get(self, req, resp, cn): def on_get(self, req, resp, cn):
path, buf, cert, attribs = authority.get_attributes(cn) path, buf, cert, attribs = self.authority.get_attributes(cn)
# TODO: are keys unique? # TODO: are keys unique?
named_tags = {} named_tags = {}
other_tags = [] other_tags = []