Websocket origin rejection warning does not mention a trusted X-Forwarded-Proto when that is the cause
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
reflex/app.py の _SocketOriginCheck.__call__ と、tests/units/test_app.py の test_socketio_rejection_warns_once_with_fix テストを読みます。信頼された X-Forwarded-Proto の値を警告に追加し、http:// オリジンがリクエストホストと一致する一方で、信頼された https と競合するケースを対象に加えます。ヒントがスキームの不一致を説明し、拒否されたオリジンを設定値として提示しないことを確認します。
索引モデルが issue の本文から書いたものです。
説明
Problem
In prod mode the event websocket accepts the backend's own origin. With trusted_proxy_hops >= 1, a trusted X-Forwarded-Proto: https makes an http:// origin a mismatch (by design, #7799). When that is the reason for a rejection, the once-per-worker warning describes the wrong cause. It prints the Host and X-Forwarded-Host it saw, then advises setting REFLEX_DEPLOY_URL and says "a reverse proxy must forward the original Host header". The Host already matches, and the real cause is the scheme: the trusted proxy claims https while the page was loaded over http, for example a misconfigured proxy or an http page behind a hop that sets X-Forwarded-Proto: https.
The rejection itself is correct; only the diagnosis is misleading.
Repro (reflex 0.11.0a2)
REFLEX_TRUSTED_PROXY_HOPS=1 REFLEX_API_URL=http://app.test:3341 reflex run --env prod --backend-port 3340(single-port).- Put a plain-http reverse proxy on :3341 that keeps
Hostand setsX-Forwarded-Proto: https. - Open
http://app.test:3341/in a browser.
Actual: the websocket gets 403 forever, and the log says:
Rejected an event websocket from origin 'http://app.test:3341': in prod mode the backend accepts only its own origin (request Host 'app.test:3341', X-Forwarded-Host None trusted); if it is your frontend's origin, set REFLEX_DEPLOY_URL on the backend to the frontend's public URL or add it to cors_allowed_origins; a reverse proxy must forward the original Host header.
Expected: the warning names the trusted X-Forwarded-Proto value it used. When the origin's host matches and only the scheme differs, the hint says so: the page is served over http while the trusted proxy reports https, so fix the proxy's X-Forwarded-Proto or serve the page over https.
Fix
reflex/app.py,_SocketOriginCheck.__call__: include the trustedX-Forwarded-Protoentry in the "request Host …, X-Forwarded-Host …" part of the warning.- When
_origin_matches_request(origin, hosts, None)is true but the call with the trusted proto is false, use a scheme-specific hint instead of the Host-forwarding one. Do not put the rejected origin into any setting's value (any client can send the first rejected handshake). - Extend
test_socketio_rejection_warns_once_with_fixintests/units/test_app.pywith anX-Forwarded-Proto: https+http://origin case attrusted_proxy_hops=1.
- 主要言語
- Python
- スター
- 29k
- フォーク
- 1.8k
- 平均マージ
- 2日 22時間
- マージ済み PR(30日)
- 154
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
reflex-dev/reflex のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
reflex-dev/reflex#7915 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Kept env.py failure: the "move it aside" hint is dropped and a full traceback is logged when alembic.ini uses a relative script_location対応中かも @MaiAditya が 4 日前に担当しました。 オープンbug release-train
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
reflex-dev/reflex#7856 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Unit tests: invoking the reflex CLI in-process leaves REFLEX_MANAGED_LOGGING=true in os.environ for every later test対応中かも @zeyadrabie が 2 日前に担当しました。 オープンrelease-train
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
reflex-dev/reflex#7844 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
A dev run stopped before its backend loads leaves .web/nocompile, so the next run or export skips the compile対応中かも @YusefSyed が 6 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
reflex-dev/reflex#7825 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
PropsBase nested serialization applies parent include/exclude filters to child fields対応中かも @harsh21234i が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
reflex-dev/reflex#7787 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
reflex-dev/reflex の issue をすべて見る
似ている issue
-
Feature Request
難易度 1/5 1〜3時間 初心者へのやさしさ 68/100
spotDL/spotify-downloader#2839 ·
メンテナーはふだん 1 日以内に返信
-
Missing license fileオープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
ops/setup.py writes ops/hub.json non-atomically (the torn-write class of #219, in the installer)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
mattabate/life-distributable#230 ·
メンテナーはふだん 1 日以内に返信
-
enhancement triage:not-checked
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
inventree/InvenTree#13318 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
google/secops-wrapper#229 ·