Skip to content

Commit

Permalink
Merge pull request #176 from ractf/feature/disable-challenge-server
Browse files Browse the repository at this point in the history
Allow disabling challenge server integrations
  • Loading branch information
david-cooke authored Aug 12, 2021
2 parents 14f1bf7 + 9e7b468 commit 0bfd9a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/andromeda/views.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
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):
permission_classes = (IsAuthenticated,)
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))


Expand All @@ -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))


Expand Down
1 change: 1 addition & 0 deletions src/backend/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0bfd9a6

Please sign in to comment.