fix(accounts): iframe 内のページをログイン画面へ戻す (issue62569) - #1902
Merged
Conversation
Sec-Fetch-Dest が 'document' 以外なら JSON を返す判定にしていたが、 'iframe' / 'frame' / 'embed' / 'object' もブラウザのナビゲーションで、 枠の中に HTML が描画される。ここに 401 JSON を返すと生の JSON が 表示され、ログインする手立てが無くなる。 invenio-previewer が制限付きファイルを <iframe> で埋め込んでいる。 HTML を描画する遷移を NAVIGATION_DESTS にまとめ、それ以外を JSON 扱いにした。 実機での確認 (/items/iframe, 未認証): Sec-Fetch-Dest 無し / document / iframe / frame / embed / object -> 302 empty / script -> 401 あわせて tests/test_unauthorized.py を新設した。この判定にテストが 無く、今回の不備もそこを突かれている。ナビゲーション5種は NAVIGATION_DESTS から自動でパラメータ化しているので、種類を足せば テストも増える。HTML フォーム POST がログイン画面へ行くことも 固定した(以前「非GETなら JSON」で壊した箇所)。16 passed。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019bkXKrjzJ2VNWVwTpDAPuZ
Claude によるレビュー指摘 0 件(コスト $0.1401) 差分のみを対象にした自動レビューです。誤りが含まれることがあります。 |
API インベントリ差分(件数のみ)
ベースラインとの差分API インベントリ差分レポート
判定: ✅ PASS (FAIL 0 / WARN 1)サマリ
[WARN] W6 依存パッケージの版が変化した — 2件
台帳との突き合わせスナップショット ↔ インベントリ 突き合わせ
判定: ✅ 一致 (0件)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #1901 のマージ後にプッシュしたため取り込まれなかった分。issue62569 の続き。
自動レビューの指摘(#1901 のコメント)への対応。
問題
未認証時に JSON を返すかどうかを
Sec-Fetch-Destで判定しているが、document以外を一律「JSON を欲しがる呼び出し」とみなしていた。iframe/frame/embed/objectもブラウザのナビゲーションで、枠の中に HTML が描画される。
@login_requiredのページを<iframe>に読み込むと、従来はログイン画面へ 302 だったものが生の JSON になり、
ログインする手立てが無くなる。
invenio-previewer が制限付きファイルを
<iframe>で埋め込んでいる。修正
HTML を描画する遷移を
NAVIGATION_DESTSにまとめ、それ以外を JSON 扱いにした。確認
実機(
/items/iframe、未認証):テスト
modules/weko-accounts/tests/test_unauthorized.pyを新設(16 passed)。この判定にテストが無く、今回の不備もそこを突かれている。
ナビゲーション5種は
NAVIGATION_DESTSから自動でパラメータ化しているので、値を足せばテストも増える。HTML フォーム POST がログイン画面へ行くことも
固定した(以前「非GETなら JSON」という規則で壊した箇所の再発防止)。