Add audit log end point

This commit is contained in:
Andrew 2023-08-20 17:03:01 -04:00
parent a8894757cf
commit 52e44f090e
2 changed files with 40 additions and 0 deletions

View File

@ -50,6 +50,7 @@ from app.classes.web.routes.api.users.user.permissions import (
from app.classes.web.routes.api.users.user.pfp import ApiUsersUserPfpHandler
from app.classes.web.routes.api.users.user.public import ApiUsersUserPublicHandler
from app.classes.web.routes.api.crafty.config.index import ApiCraftyConfigIndexHandler
from app.classes.web.routes.api.crafty.clogs.index import ApiCraftyLogIndexHandler
def api_handlers(handler_args):
@ -70,6 +71,11 @@ def api_handlers(handler_args):
ApiCraftyConfigIndexHandler,
handler_args,
),
(
r"/api/v2/crafty/logs/([a-z0-9_]+)/?",
ApiCraftyLogIndexHandler,
handler_args,
),
# User routes
(
r"/api/v2/users/?",

View File

@ -0,0 +1,34 @@
from app.classes.web.base_api_handler import BaseApiHandler
class ApiCraftyLogIndexHandler(BaseApiHandler):
def get(self, log_type: str):
auth_data = self.authenticate_user()
if not auth_data:
return
(
_,
_,
_,
superuser,
_,
) = auth_data
if not superuser:
return self.finish_json(400, {"status": "error", "error": "NOT_AUTHORIZED"})
log_types = ["audit", "session", "schedule"]
if log_type not in log_types:
raise NotImplementedError
if log_type == "audit":
return self.finish_json(
200,
{"status": "ok", "data": self.controller.management.get_activity_log()},
)
if log_type == "session":
raise NotImplementedError
if log_type == "schedule":
raise NotImplementedError