From 9e7b468588a6bc23f08293e787dbf4588f1969e7 Mon Sep 17 00:00:00 2001 From: David Cooke Date: Thu, 12 Aug 2021 00:56:16 +0100 Subject: [PATCH] Allow disabling challenge server integrations --- src/andromeda/views.py | 6 ++++++ src/backend/settings/__init__.py | 1 + 2 files changed, 7 insertions(+) diff --git a/src/andromeda/views.py b/src/andromeda/views.py index fff99f3f..f737365c 100644 --- a/src/andromeda/views.py +++ b/src/andromeda/views.py @@ -1,11 +1,13 @@ from rest_framework.generics import get_object_or_404 from rest_framework.permissions import IsAdminUser, IsAuthenticated +from rest_framework.status import HTTP_400_BAD_REQUEST from rest_framework.views import APIView from andromeda import client from andromeda.serializers import JobSubmitSerializer from backend.response import FormattedResponse from challenge.models import Challenge +from config import config class GetInstanceView(APIView): @@ -13,6 +15,8 @@ class GetInstanceView(APIView): throttle_scope = "challenge_instance_get" def get(self, request, job_id): + if not config.get("enable_challenge_server"): + return FormattedResponse(m="challenge_server_disabled", status=HTTP_400_BAD_REQUEST) return FormattedResponse(client.get_instance(request.user.id, job_id)) @@ -21,6 +25,8 @@ class ResetInstanceView(APIView): throttle_scope = "challenge_instance_reset" def get(self, request, job_id): + if not config.get("enable_challenge_server"): + return FormattedResponse(m="challenge_server_disabled", status=HTTP_400_BAD_REQUEST) return FormattedResponse(client.request_reset(request.user.id, job_id)) diff --git a/src/backend/settings/__init__.py b/src/backend/settings/__init__.py index 4805f95b..b9444fe4 100644 --- a/src/backend/settings/__init__.py +++ b/src/backend/settings/__init__.py @@ -64,6 +64,7 @@ "token_provider": "basic_auth", "enable_bot_users": True, "enable_caching": True, + "enable_challenge_server": True, "enable_ctftime": True, "enable_flag_submission": True, "enable_flag_submission_after_competition": True,