Add option for bridge to create new judge
This commit is contained in:
parent
daee631ef6
commit
1e88e73082
3 changed files with 15 additions and 4 deletions
|
@ -381,6 +381,7 @@ BRIDGED_JUDGE_ADDRESS = [("localhost", 9999)]
|
||||||
BRIDGED_JUDGE_PROXIES = None
|
BRIDGED_JUDGE_PROXIES = None
|
||||||
BRIDGED_DJANGO_ADDRESS = [("localhost", 9998)]
|
BRIDGED_DJANGO_ADDRESS = [("localhost", 9998)]
|
||||||
BRIDGED_DJANGO_CONNECT = None
|
BRIDGED_DJANGO_CONNECT = None
|
||||||
|
BRIDGED_AUTO_CREATE_JUDGE = False
|
||||||
|
|
||||||
# Event Server configuration
|
# Event Server configuration
|
||||||
EVENT_DAEMON_USE = False
|
EVENT_DAEMON_USE = False
|
||||||
|
|
|
@ -123,11 +123,21 @@ class JudgeHandler(ZlibPacketHandler):
|
||||||
|
|
||||||
def _authenticate(self, id, key):
|
def _authenticate(self, id, key):
|
||||||
try:
|
try:
|
||||||
judge = Judge.objects.get(name=id, is_blocked=False)
|
judge = Judge.objects.get(name=id)
|
||||||
except Judge.DoesNotExist:
|
except Judge.DoesNotExist:
|
||||||
result = False
|
if settings.BRIDGED_AUTO_CREATE_JUDGE:
|
||||||
|
judge = Judge()
|
||||||
|
judge.name = id
|
||||||
|
judge.auth_key = key
|
||||||
|
judge.save()
|
||||||
|
result = True
|
||||||
|
else:
|
||||||
|
result = False
|
||||||
else:
|
else:
|
||||||
result = hmac.compare_digest(judge.auth_key, key)
|
if judge.is_blocked:
|
||||||
|
result = False
|
||||||
|
else:
|
||||||
|
result = hmac.compare_digest(judge.auth_key, key)
|
||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
json_log.warning(
|
json_log.warning(
|
||||||
|
|
|
@ -26,7 +26,7 @@ pyotp
|
||||||
qrcode[pil]
|
qrcode[pil]
|
||||||
jsonfield @ git+https://github.com/DMOJ/jsonfield.git
|
jsonfield @ git+https://github.com/DMOJ/jsonfield.git
|
||||||
pymoss
|
pymoss
|
||||||
packaging<23
|
packaging<22
|
||||||
celery
|
celery
|
||||||
ansi2html @ git+https://github.com/DMOJ/ansi2html.git
|
ansi2html @ git+https://github.com/DMOJ/ansi2html.git
|
||||||
sqlparse
|
sqlparse
|
||||||
|
|
Loading…
Reference in a new issue