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

View File

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