From 6c9478e400746cd3fd45f5dca5a81b2a4545642e Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Sat, 10 Dec 2022 14:12:11 -0700 Subject: [PATCH] Create a view for dumping the DB --- projects/activitypub_relay/src/python/relay/views.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/projects/activitypub_relay/src/python/relay/views.py b/projects/activitypub_relay/src/python/relay/views.py index 13094ef..3215585 100644 --- a/projects/activitypub_relay/src/python/relay/views.py +++ b/projects/activitypub_relay/src/python/relay/views.py @@ -277,6 +277,17 @@ def get_config(request: Request): return Response.new(request.app.config, status=200, ctype="json") +@register_route("GET", "/admin/db") +def get_db(request: Request): + if not (auth := request.headers.get("Authorization")): + return Response.new_error(403, "access denied", "json") + + if not auth == f"Bearer {request.app.config.admin_token}": + return Response.new_error(403, "access denied", "json") + + return Response.new(request.app.database, status=200, ctype="json") + + @register_route("GET", "/admin/pending") def get_pending(request): if not (auth := request.headers.get("Authorization")):