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

Add support for [*] in trusted hosts #2480

Merged
merged 3 commits into from
Oct 9, 2024

Conversation

theyashl
Copy link
Contributor

@theyashl theyashl commented Oct 2, 2024

Summary

Fixed trusted host parsing for always trust case.
This PR will fix allowing all networks upon passing --forwarded-allow-ips as * from gunicorn with uvicorn as a worker class.

The fix ensures that gunicorn integration and uvicorn as a standalone application will work fine for storing and validating trusted networks.

Complete RCA is present on issue: #2477

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@theyashl
Copy link
Contributor Author

theyashl commented Oct 2, 2024

@Kludex requesting your review and inputs for this PR :)

@@ -65,7 +65,7 @@ def make_httpx_client(
"::11.22.33.44", # This is a dual address
]
_TRUSTED_IPv6_NETWORKS = "2001:db8:abcd:0012::0/64"
_TRUSTED_LITERALS = "some-literal , unix:///foo/bar , /foo/bar"
_TRUSTED_LITERALS = "some-literal , unix:///foo/bar , /foo/bar, garba*gewith*"
Copy link
Member

@Kludex Kludex Oct 5, 2024

Choose a reason for hiding this comment

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

We probably have an assertive test case with *, can you add [*] as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added test case with trust host using ["*"], It's similar to the existing trust everything so I did not add every address as an input.

@Kludex
Copy link
Member

Kludex commented Oct 5, 2024

Please change the title as well.

@theyashl theyashl changed the title Fix 'always trust networks' case for gunicorn Fix forwarded allow IPs handling Oct 5, 2024
@theyashl theyashl requested a review from Kludex October 7, 2024 13:41
@Kludex Kludex changed the title Fix forwarded allow IPs handling Add support for [*] in trusted hosts Oct 9, 2024
Copy link
Member

@Kludex Kludex left a comment

Choose a reason for hiding this comment

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

Thanks. :)

@Kludex Kludex merged commit a1783d8 into encode:master Oct 9, 2024
15 checks passed
raf-moreau pushed a commit to raf-moreau/uvicorn that referenced this pull request Nov 5, 2024
* fixed trusted host parsing for always trust case

* Update uvicorn/middleware/proxy_headers.py

* added test case for trust everything using list

---------

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
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