Skip to content

Add middleware to ban bytedance user agent #1347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 27, 2023

Conversation

TG1999
Copy link
Contributor

@TG1999 TG1999 commented Nov 26, 2023

No description provided.

@TG1999 TG1999 force-pushed the ban_bytedance_user_agent branch from a49a18e to da95d01 Compare November 26, 2023 21:55
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM... just a minor nit.

def process_request(self, request):
user_agent = request.META.get("HTTP_USER_AGENT", None)
if user_agent and "bytedance" in user_agent:
return HttpResponseForbidden("You are banned!", content_type="text/html")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not provide insights to the spammer caller in this case.
Use a HttpResponseNotFound (404) instead fully empty and no message.

Signed-off-by: Tushar Goel <[email protected]>
@TG1999 TG1999 merged commit fca8815 into aboutcode-org:main Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants