diff options
author | Paolo Melchiorre | 2022-12-05 22:44:50 +0100 |
---|---|---|
committer | GitHub | 2022-12-05 14:44:50 -0700 |
commit | 22e25ac454b52686685d4d9f1241416cd35fafda (patch) | |
tree | 6796235a63e5e9dd549f29a640bbb2e6c0de17a0 /core | |
parent | e3f1039a5f976af1c9874e79bcaac396b7b8b4f2 (diff) | |
download | takahe-22e25ac454b52686685d4d9f1241416cd35fafda.tar.gz takahe-22e25ac454b52686685d4d9f1241416cd35fafda.tar.bz2 takahe-22e25ac454b52686685d4d9f1241416cd35fafda.zip |
Add django-upgrade to pre-commit (#114)
Diffstat (limited to 'core')
-rw-r--r-- | core/signatures.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/core/signatures.py b/core/signatures.py index 640483a..d0443c3 100644 --- a/core/signatures.py +++ b/core/signatures.py @@ -142,19 +142,19 @@ class HttpSignature: Verifies that the request has a valid signature for its body """ # Verify body digest - if "HTTP_DIGEST" in request.META: + if "digest" in request.headers: expected_digest = HttpSignature.calculate_digest(request.body) - if request.META["HTTP_DIGEST"] != expected_digest: + if request.headers["digest"] != expected_digest: raise VerificationFormatError("Digest is incorrect") # Verify date header - if "HTTP_DATE" in request.META and not skip_date: - header_date = parse_http_date(request.META["HTTP_DATE"]) + if "date" in request.headers and not skip_date: + header_date = parse_http_date(request.headers["date"]) if abs(timezone.now().timestamp() - header_date) > 60: raise VerificationFormatError("Date is too far away") # Get the signature details - if "HTTP_SIGNATURE" not in request.META: + if "signature" not in request.headers: raise VerificationFormatError("No signature header present") - signature_details = cls.parse_signature(request.META["HTTP_SIGNATURE"]) + signature_details = cls.parse_signature(request.headers["signature"]) # Reject unknown algorithms if signature_details["algorithm"] != "rsa-sha256": raise VerificationFormatError("Unknown signature algorithm") |