mirror of
https://github.com/laurivosandi/certidude
synced 2026-01-13 01:17:00 +00:00
api: Make logger use unicode literals
This commit is contained in:
@@ -90,9 +90,9 @@ class SessionResource(object):
|
||||
)
|
||||
|
||||
if req.context.get("user").is_admin():
|
||||
logger.info("Logged in authority administrator %s from %s" % (req.context.get("user"), req.context.get("remote_addr")))
|
||||
logger.info(u"Logged in authority administrator %s from %s" % (req.context.get("user"), req.context.get("remote_addr")))
|
||||
else:
|
||||
logger.info("Logged in authority user %s from %s" % (req.context.get("user"), req.context.get("remote_addr")))
|
||||
logger.info(u"Logged in authority user %s from %s" % (req.context.get("user"), req.context.get("remote_addr")))
|
||||
return dict(
|
||||
user = dict(
|
||||
name=req.context.get("user").name,
|
||||
@@ -156,11 +156,11 @@ class StaticResource(object):
|
||||
if content_encoding:
|
||||
resp.append_header("Content-Encoding", content_encoding)
|
||||
resp.stream = open(path, "rb")
|
||||
logger.debug("Serving '%s' from '%s'", req.path, path)
|
||||
logger.debug(u"Serving '%s' from '%s'", req.path, path)
|
||||
else:
|
||||
resp.status = falcon.HTTP_404
|
||||
resp.body = "File '%s' not found" % req.path
|
||||
logger.info("Fail '%s' not found, path resolved to '%s'", req.path, path)
|
||||
logger.info(u"File '%s' not found, path resolved to '%s'", req.path, path)
|
||||
import ipaddress
|
||||
|
||||
class NormalizeMiddleware(object):
|
||||
|
||||
@@ -81,7 +81,7 @@ class RequestListResource(object):
|
||||
try:
|
||||
renewal_signature = b64decode(renewal_header)
|
||||
except TypeError, ValueError:
|
||||
logger.error("Renewal failed, bad signature supplied for %s", common_name.value)
|
||||
logger.error(u"Renewal failed, bad signature supplied for %s", common_name.value)
|
||||
reasons.append("Renewal failed, bad signature supplied")
|
||||
else:
|
||||
try:
|
||||
@@ -97,20 +97,20 @@ class RequestListResource(object):
|
||||
verifier.update(body)
|
||||
verifier.verify()
|
||||
except InvalidSignature:
|
||||
logger.error("Renewal failed, invalid signature supplied for %s", common_name.value)
|
||||
logger.error(u"Renewal failed, invalid signature supplied for %s", common_name.value)
|
||||
reasons.append("Renewal failed, invalid signature supplied")
|
||||
else:
|
||||
# At this point renewal signature was valid but we need to perform some extra checks
|
||||
if datetime.utcnow() > cert.not_valid_after:
|
||||
logger.error("Renewal failed, current certificate for %s has expired", common_name.value)
|
||||
logger.error(u"Renewal failed, current certificate for %s has expired", common_name.value)
|
||||
reasons.append("Renewal failed, current certificate expired")
|
||||
elif not config.CERTIFICATE_RENEWAL_ALLOWED:
|
||||
logger.error("Renewal requested for %s, but not allowed by authority settings", common_name.value)
|
||||
logger.error(u"Renewal requested for %s, but not allowed by authority settings", common_name.value)
|
||||
reasons.append("Renewal requested, but not allowed by authority settings")
|
||||
else:
|
||||
resp.set_header("Content-Type", "application/x-x509-user-cert")
|
||||
_, resp.body = authority._sign(csr, body, overwrite=True)
|
||||
logger.info("Renewed certificate for %s", common_name.value)
|
||||
logger.info(u"Renewed certificate for %s", common_name.value)
|
||||
return
|
||||
|
||||
|
||||
@@ -125,10 +125,10 @@ class RequestListResource(object):
|
||||
try:
|
||||
resp.set_header("Content-Type", "application/x-pem-file")
|
||||
_, resp.body = authority._sign(csr, body)
|
||||
logger.info("Autosigned %s as %s is whitelisted", common_name.value, req.context.get("remote_addr"))
|
||||
logger.info(u"Autosigned %s as %s is whitelisted", common_name.value, req.context.get("remote_addr"))
|
||||
return
|
||||
except EnvironmentError:
|
||||
logger.info("Autosign for %s from %s failed, signed certificate already exists",
|
||||
logger.info(u"Autosign for %s from %s failed, signed certificate already exists",
|
||||
common_name.value, req.context.get("remote_addr"))
|
||||
reasons.append("Autosign failed, signed certificate already exists")
|
||||
break
|
||||
|
||||
@@ -34,5 +34,5 @@ class ScriptResource():
|
||||
other_tags=other_tags,
|
||||
named_tags=named_tags,
|
||||
attributes=attribs.get("user").get("machine"))
|
||||
logger.info("Served script %s for %s at %s" % (script, cn, req.context["remote_addr"]))
|
||||
logger.info(u"Served script %s for %s at %s" % (script, cn, req.context["remote_addr"]))
|
||||
# TODO: Assert time is within reasonable range
|
||||
|
||||
@@ -38,7 +38,7 @@ class SignedCertificateDetailResource(object):
|
||||
logger.debug(u"Served certificate %s to %s as application/json",
|
||||
cn, req.context.get("remote_addr"))
|
||||
else:
|
||||
logger.debug("Client did not accept application/json or application/x-pem-file")
|
||||
logger.debug(u"Client did not accept application/json or application/x-pem-file")
|
||||
raise falcon.HTTPUnsupportedMediaType(
|
||||
"Client did not accept application/json or application/x-pem-file")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user