Skip to content

Commit

Permalink
Update unisender_go.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeVL authored Aug 30, 2024
1 parent 9d4fb5d commit 1ea32ec
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions anymail/webhooks/unisender_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ def validate_request(self, request: HttpRequest) -> None:
So it is both auth and encryption. Also, they hash JSON without spaces.
"""
request_json = json.loads(request.body.decode("utf-8"))
request_body = request.body.decode("utf-8")
request_json = json.loads(request_body)
request_auth = request_json.get("auth", "")
request_json["auth"] = get_anymail_setting(
"api_key", esp_name=self.esp_name, allow_bare=True
json_with_key = request_body.replace(
request_auth, get_anymail_setting("api_key", esp_name=self.esp_name, allow_bare=True)
)
json_with_key = json.dumps(request_json, separators=(",", ":"))

expected_auth = md5(json_with_key.encode("utf-8")).hexdigest()

if not constant_time_compare(request_auth, expected_auth):
Expand Down

0 comments on commit 1ea32ec

Please sign in to comment.