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

api: signed: drop usage of global authority import

This commit is contained in:
Priit Laes 2018-02-03 12:55:42 +02:00
parent 29f3e1fce9
commit 4e50ddfc54
2 changed files with 6 additions and 4 deletions

View File

@ -219,7 +219,7 @@ def certidude_app(log_handlers=[]):
# Certificate authority API calls # Certificate authority API calls
app.add_route("/api/certificate/", CertificateAuthorityResource()) app.add_route("/api/certificate/", CertificateAuthorityResource())
app.add_route("/api/signed/{cn}/", SignedCertificateDetailResource()) app.add_route("/api/signed/{cn}/", SignedCertificateDetailResource(authority))
app.add_route("/api/request/{cn}/", RequestDetailResource(authority)) app.add_route("/api/request/{cn}/", RequestDetailResource(authority))
app.add_route("/api/request/", RequestListResource(authority)) app.add_route("/api/request/", RequestListResource(authority))
app.add_route("/api/", SessionResource()) app.add_route("/api/", SessionResource())

View File

@ -3,7 +3,6 @@ import falcon
import logging import logging
import json import json
import hashlib import hashlib
from certidude import authority
from certidude.auth import login_required, authorize_admin from certidude.auth import login_required, authorize_admin
from certidude.decorators import csrf_protection from certidude.decorators import csrf_protection
from xattr import getxattr from xattr import getxattr
@ -11,11 +10,14 @@ from xattr import getxattr
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class SignedCertificateDetailResource(object): class SignedCertificateDetailResource(object):
def __init__(self, authority):
self.authority = authority
def on_get(self, req, resp, cn): def on_get(self, req, resp, cn):
preferred_type = req.client_prefers(("application/json", "application/x-pem-file")) preferred_type = req.client_prefers(("application/json", "application/x-pem-file"))
try: try:
path, buf, cert, signed, expires = authority.get_signed(cn) path, buf, cert, signed, expires = self.authority.get_signed(cn)
except EnvironmentError: except EnvironmentError:
logger.warning("Failed to serve non-existant certificate %s to %s", logger.warning("Failed to serve non-existant certificate %s to %s",
cn, req.context.get("remote_addr")) cn, req.context.get("remote_addr"))
@ -55,5 +57,5 @@ class SignedCertificateDetailResource(object):
def on_delete(self, req, resp, cn): def on_delete(self, req, resp, cn):
logger.info("Revoked certificate %s by %s from %s", logger.info("Revoked certificate %s by %s from %s",
cn, req.context.get("user"), req.context.get("remote_addr")) cn, req.context.get("user"), req.context.get("remote_addr"))
authority.revoke(cn) self.authority.revoke(cn)