fix: name a forwarded scheme mismatch in the origin rejection warning
Merged
MA
3d ago+59+59+01234567890123456789-11-11-01234567890123456789
Closes #7857
With trusted_proxy_hops >= 1, a trusted X-Forwarded-Proto: https correctly rejects an http:// origin, but the once-per-worker warning printed only Host / X-Forwarded-Host and advised setting REFLEX_DEPLOY_URL and forwarding the original Host header, even when the Host already matched.
_SocketOriginCheck.__call__now keeps the request hosts and the trustedX-Forwarded-Protoentry in locals, and the warning's parenthetical names that entry when proxies are trusted (X-Forwarded-Host None trusted, X-Forwarded-Proto 'https' trusted). Withtrusted_proxy_hops0 the text is unchanged.- When the origin matches the request's hosts once the scheme is ignored (
_origin_matches_request(origin, hosts, None)), the hint says the page was loaded over http but the trustedX-Forwarded-Protosays https, so fix the reverse proxy'sX-Forwarded-Protoor serve the page over https. The rejected origin is still never put into a setting's value. - The accept/reject decision is unchanged.
Tests: a new X-Forwarded-Proto: https + http:// origin case at trusted_proxy_hops=1 in test_socketio_rejection_warns_once_with_fix, and test_socketio_rejection_names_forwarded_proto_mismatch, which compares the full warning from the reflex.app logger against the issue's repro (http://app.test:3341). Both fail on main. pytest tests/units/test_app.py tests/units/test_config.py: 489 passed; ruff check/format clean.
All Submissions:
- Have you followed the guidelines stated in CONTRIBUTING.md file?
- Have you checked to ensure there aren't any other open Pull Requests for the desired changed?
Type of change
- Bug fix (non-breaking change which fixes an issue)
Changes To Core Features:
- Have you added an explanation of what your changes do and why you'd like us to include them?
- Have you written new tests for your core changes, as applicable?
- Have you successfully ran tests with your changes locally?