From 92cef5bfd1f2fe566bc51dbe39f314b9a3850c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bonhomme?= Date: Mon, 29 Jul 2024 11:20:46 +0200 Subject: [PATCH] new: [API] Added new endpoint (/configInfo) which returns non-sensitive information about the configuration of the system. --- website/web/api/v1/base.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/website/web/api/v1/base.py b/website/web/api/v1/base.py index af8b2e18..d56fcdbf 100644 --- a/website/web/api/v1/base.py +++ b/website/web/api/v1/base.py @@ -12,10 +12,12 @@ from flask_restx import Resource from redis import Redis +from vulnerabilitylookup import __version__ from vulnerabilitylookup.default import get_config from vulnerabilitylookup.helpers import fromisoformat_wrapper from website.validators import validate_json from website.web.api.v1.common import auth_func +from website.web.bootstrap import application from website.web.bootstrap import vulnerabilitylookup from website.web.permissions import reporter_permission, admin_permission @@ -183,6 +185,22 @@ def get(self) -> dict[str, Any]: return vulnerabilitylookup.get_info() +@api_ns.route("/configInfo") +@default_ns.route("configInfo") +@api_ns.doc( + description="Get non-sensitive information about the configuration of the system." +) +class ConfigInfo(Resource): # type: ignore[misc] + def get(self) -> dict[str, Any]: + return { + "user_accounts": get_config("generic", "user_accounts"), + "local_instance_uuid": get_config("generic", "local_instance_uuid"), + "registration": application.config["SELF_REGISTRATION"], + "moderation": application.config["COMMENTS_MODERATION"], + "software_version": __version__, + } + + @api_ns.route("/last") @default_ns.route("last") @default_ns.route("last/")