Skip to content

Commit

Permalink
new: [API] Added new endpoint (/configInfo) which returns non-sensiti…
Browse files Browse the repository at this point in the history
…ve information about the configuration of the system.
  • Loading branch information
cedricbonhomme committed Jul 29, 2024
1 parent 0e7de26 commit 92cef5b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions website/web/api/v1/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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/<int:number>")
Expand Down

0 comments on commit 92cef5b

Please sign in to comment.