1
0
mirror of https://github.com/laurivosandi/certidude synced 2024-11-04 20:38:12 +00:00

api: attrib: drop usage of global authority import

This commit is contained in:
Priit Laes 2018-02-03 12:37:06 +02:00
parent 5cb7f89c1b
commit 863deafa59
2 changed files with 6 additions and 5 deletions

View File

@ -228,7 +228,7 @@ def certidude_app(log_handlers=[]):
app.add_route("/api/token/", TokenResource()) app.add_route("/api/token/", TokenResource())
# Extended attributes for scripting etc. # Extended attributes for scripting etc.
app.add_route("/api/signed/{cn}/attr/", AttributeResource(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())
# API calls used by pushed events on the JS end # API calls used by pushed events on the JS end

View File

@ -4,7 +4,7 @@ import logging
import re import re
from xattr import setxattr, listxattr, removexattr from xattr import setxattr, listxattr, removexattr
from datetime import datetime from datetime import datetime
from certidude import config, authority, push from certidude import push
from certidude.decorators import serialize, csrf_protection from certidude.decorators import serialize, csrf_protection
from certidude.firewall import whitelist_subject from certidude.firewall import whitelist_subject
from certidude.auth import login_required, login_optional, authorize_admin from certidude.auth import login_required, login_optional, authorize_admin
@ -13,7 +13,8 @@ from ipaddress import ip_address
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class AttributeResource(object): class AttributeResource(object):
def __init__(self, namespace): def __init__(self, authority, namespace):
self.authority = authority
self.namespace = namespace self.namespace = namespace
@serialize @serialize
@ -27,7 +28,7 @@ class AttributeResource(object):
Results made available only to lease IP address. Results made available only to lease IP address.
""" """
try: try:
path, buf, cert, attribs = authority.get_attributes(cn, namespace=self.namespace) path, buf, cert, attribs = self.authority.get_attributes(cn, namespace=self.namespace)
except IOError: except IOError:
raise falcon.HTTPNotFound() raise falcon.HTTPNotFound()
else: else:
@ -38,7 +39,7 @@ class AttributeResource(object):
def on_post(self, req, resp, cn): def on_post(self, req, resp, cn):
namespace = ("user.%s." % self.namespace).encode("ascii") namespace = ("user.%s." % self.namespace).encode("ascii")
try: try:
path, buf, cert, signed, expires = authority.get_signed(cn) path, buf, cert, signed, expires = self.authority.get_signed(cn)
except IOError: except IOError:
raise falcon.HTTPNotFound() raise falcon.HTTPNotFound()
else: else: