Skip to content

Commit

Permalink
Block Andromeda instance requests if not in team (#228)
Browse files Browse the repository at this point in the history
Resolves #227
  • Loading branch information
thebeanogamer authored Jan 16, 2022
1 parent c2a44f3 commit 3d19bd4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/andromeda/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
from andromeda.serializers import JobSubmitSerializer
from backend.response import FormattedResponse
from challenge.models import Challenge
from challenge.permissions import CompetitionOpen
from config import config


class GetInstanceView(APIView):
permission_classes = (IsAuthenticated,)
permission_classes = (IsAuthenticated, CompetitionOpen)
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_403_FORBIDDEN)
if not request.user.team:
return FormattedResponse(m="challenge_server_team_required", status=HTTP_403_FORBIDDEN)
return FormattedResponse(client.get_instance(request.user.team.id, job_id))


Expand Down

0 comments on commit 3d19bd4

Please sign in to comment.