Implement max inbound payload size

pull/303/head
Andrew Godwin 2022-12-27 20:01:00 -07:00
rodzic 1fc5740696
commit 5780068213
2 zmienionych plików z 5 dodań i 0 usunięć

Wyświetl plik

@ -312,6 +312,8 @@ CORS_ORIGIN_WHITELIST = SETUP.CORS_HOSTS
CORS_ALLOW_CREDENTIALS = True
CORS_PREFLIGHT_MAX_AGE = 604800
JSONLD_MAX_SIZE = 1024 * 50 # 50 KB
CSRF_TRUSTED_ORIGINS = SETUP.CSRF_HOSTS
MEDIA_URL = SETUP.MEDIA_URL

Wyświetl plik

@ -120,6 +120,9 @@ class Inbox(View):
"""
def post(self, request, handle=None):
# Reject bodies that are unfeasibly big
if len(request.body) > settings.JSONLD_MAX_SIZE:
return HttpResponseBadRequest("Payload size too large")
# Load the LD
document = canonicalise(json.loads(request.body), include_security=True)
# Find the Identity by the actor on the incoming item