Skip to content
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

[feature] Allow customizable request filtering by user-agent #1296

Closed
tsmethurst opened this issue Jan 3, 2023 · 1 comment · Fixed by #2893
Closed

[feature] Allow customizable request filtering by user-agent #1296

tsmethurst opened this issue Jan 3, 2023 · 1 comment · Fixed by #2893
Labels
config Something needs to be made configurable, or there's a config issue enhancement New feature or request security
Milestone

Comments

@tsmethurst
Copy link
Contributor

tsmethurst commented Jan 3, 2023

Right now we have an http middleware which aborts incoming http requests that don't have any user-agent set on them, returning code 418 I'm A Teapot, in order to force http callers to at least provide some kind of identification in order to use the API (though this identification is ofc not reliable since it can be trivially spoofed).

However, since user-agent is not actually a required header, and only a 'should' (https://www.rfc-editor.org/rfc/rfc7231#section-5.5.3), then we ought to make this behavior configurable by the instance admin (see #1292) to let them choose whether empty user agents get the teapot treatment.

Connected to this, we should expand the user-agent middleware to also allow admins to provide a list of regular expressions that will be evaluated against the incoming user-agent header string. This will be useful in filtering out unwanted scraping from bots with a predictable user-agent, which do not respect robots.txt or robots meta tags.

Could also be used by admins who want to completely limit interaction with other fedi softwares that use predictable user-agent strings.

Config key could be something like advanced-user-agent-filters, with the value as an array/slice of regex strings. The default value would, i guess, replicate the existing behavior (so just one entry, which matches empty strings)

@tsmethurst tsmethurst added enhancement New feature or request security config Something needs to be made configurable, or there's a config issue labels Jan 3, 2023
@tsmethurst tsmethurst added this to the v0.14.0 milestone Dec 16, 2023
@NyaaaWhatsUpDoc
Copy link
Member

this is handled in #2409

only thing that would be useful is some kind of frontend for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Something needs to be made configurable, or there's a config issue enhancement New feature or request security
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants