Python code style fixes

This commit is contained in:
Marvin Martinson 2021-08-11 19:43:55 +00:00
parent 08c9a1c7ec
commit 31d4dad2be
2 changed files with 15 additions and 7 deletions

View File

@ -1,6 +1,4 @@
import falcon
import logging
import binascii
import click
import gssapi
@ -29,6 +27,7 @@ whitelist_blocked_requests = Counter(
logger = LogHandler()
def whitelist_subnets(subnets):
"""
Validate source IP address of API call against subnet list
@ -213,9 +212,11 @@ def authenticate(optional=False):
def login_required(func):
return authenticate()(func)
def login_optional(func):
return authenticate(optional=True)(func)
def authorize_admin(func):
@whitelist_subnets(const.ADMIN_SUBNETS)
def wrapped(resource, req, resp, *args, **kwargs):
@ -231,6 +232,7 @@ def authorize_server(func):
Make sure the request originator has a certificate with server flags
"""
from asn1crypto import pem, x509
def wrapped(resource, req, resp, *args, **kwargs):
buf = req.get_header("X-SSL-CERT")
if not buf:

View File

@ -1,5 +1,6 @@
import time
class LoggerObject(object):
msg = None
args = None
@ -11,12 +12,16 @@ class CertidudeLogger(object):
def info(self, msg, *args):
self.pre_emit(msg, *args, level="Info")
def warning(self, msg, *args):
self.pre_emit(msg, *args, level="Warning")
def error(self, msg, *args):
self.pre_emit(msg, *args, level="Error")
def debug(self, msg, *args):
self.pre_emit(msg, *args, level="Debug")
def pre_emit(self, msg, *args, level):
record = LoggerObject()
record.msg = msg
@ -24,5 +29,6 @@ class CertidudeLogger(object):
record.levelname = level
record.created = time.time()
self.emit(record)
def emit(self,record):
console.log(record)
def emit(self, record):
pass