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

configure and check request.trusted_hosts #5637

Merged
merged 1 commit into from
Nov 13, 2024
Merged

configure and check request.trusted_hosts #5637

merged 1 commit into from
Nov 13, 2024

Conversation

davidism
Copy link
Member

Add TRUSTED_HOSTS config. In Flask.create_url_adapter, which is called when creating a RequestContext, set request.trusted_hosts to the config. Call get_host with the config, and assign it to request.host to pre-cache the property.

I considered making flask.Request.trusted_hosts a property, so that setting it would trigger validation again automatically. I'm not confident this difference in behavior from Werkzeug, where only accessing request.host triggers validation, would be good. If it's a good idea, it can be done in Werkzeug.

fixes #5636

@davidism davidism added this to the 3.1.0 milestone Nov 13, 2024
@davidism davidism marked this pull request as ready for review November 13, 2024 05:02
@davidism davidism merged commit 7b21d43 into main Nov 13, 2024
13 checks passed
@davidism davidism deleted the trusted_hosts branch November 13, 2024 05:03
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

configure and check request.trusted_hosts
1 participant