Skip to content

Commit

Permalink
Use the IP address of the client that connected to CloudFront
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed Sep 25, 2024
1 parent 94dbb67 commit 92ab335
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion wcivf/apps/feedback/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def is_spam(self):
akismet_client = akismet.SyncClient.validated_client(config=config)

return akismet_client.comment_check(
user_ip=self.request.META["REMOTE_ADDR"],
# The IP address of the client that connected to CloudFront,
# not the IP of the connecting client (ALB or CloudFront).
user_ip=self.request.META["HTTP_X_FORWARDED_FOR"]
.split(",")[0]
.strip(),
comment_content=self.request.POST.get("comments"),
comment_type="feedback",
comment_author=self.request.META.get("HTTP_USER_AGENT"),
Expand Down

0 comments on commit 92ab335

Please sign in to comment.