widget/receiver: ingest key による widget↔receiver ペア認証を追加する (#44) - #106
Merged
Conversation
公開デプロイで唯一無認証だった受信面(POST /feedback)を保護する。
- receiver: INGEST_KEYS env(カンマ区切り)/ config ingestKeys(配列)を
追加。設定時は X-PatchLoop-Ingest-Key ヘッダーの一致を必須にし、
欠落・不一致は 401。route table の auth kind "ingest" として宣言し、
dispatch で一元適用(timing-safe 比較)
- config の { key, projectId } 形式で key と projectId を紐付けでき、
紐付き key での投稿は payload の projectId 詐称を 403 で拒否、
省略時は key の projectId を補完(必ず帰属が付く)
- CORS の Access-Control-Allow-Headers に X-PatchLoop-Ingest-Key を追加
(忘れると preflight で widget 送信が全滅する — issue の設計メモ)
- widget: init option ingestKey を追加し、receiver POST にヘッダーで送る
- 起動ログに ingest auth の有効/無効を出力。未設定は従来通り誰でも投稿
できるゼロ設定互換
キーはデモページに埋め込まれる公開キーで、秘密による認証ではない
(プロジェクト識別・無差別 spam 抑止・ローテーション失効が目的)。
レビュアー個人の認証は将来スコープ(README の境界に明記)。
Closes #44
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LRdDjwxbAAaTMwwnzipkau
Owner
Author
🔍 レビュー依頼(→ Codex)
|
ingest key は公開キーで unforgeable ではないため、コメントの文言を 「ingest key / project binding と並ぶ弱シグナル」に更新(Codex レビュー 🟡)。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LRdDjwxbAAaTMwwnzipkau
Owner
Author
📋 レビュー結果(by Codex GPT-5.5)判定: ✅ merge 可(must 0 件) — 🟡 should 1 件(下記、対応済み)/ ⚪ nit 0 件 🔴 mustなし 🟡 should
⚪ nitなし レビュアーの検証範囲(要旨)route table / dispatch / rate limit・CORS・auth の順序 / |
kosako
marked this pull request as ready for review
July 5, 2026 13:30
kosako
added a commit
that referenced
this pull request
Jul 5, 2026
#103(inbox ログイン + CORS 制限)・#104(healthz / graceful shutdown / 設定警告)・#106(ingest key)で README.md に入れた receiver 契約の変更を 英語版にミラーする: - RECEIVER_TOKEN の説明を「閲覧系も保護 + inbox ログイン(HMAC cookie)」に更新 - INGEST_KEYS / ALLOWED_ORIGINS の項目を追加 - healthz・graceful shutdown・invalid setting warning を追記 - Public Deployment (EC2 etc.) 節を新設 - Init options に ingestKey を追加、Current Boundary の Auth 行を更新 Closes #105 Claude-Session: https://claude.ai/code/session_01LRdDjwxbAAaTMwwnzipkau Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.
概要
Issue #44 の本体。公開デプロイで唯一無認証だった受信面(
POST /feedback)に、プロジェクトごとの公開キー(ingest key)による軽量なペア認証を追加します。#44 の他項目(SVG stored XSS の CSP 封じ、DoS 上限、payload shape 検証)は #90/#92/#93 で対応済みです。前提(Issue の設計方針)
ページに埋め込むキーは閲覧者全員に見えるため、秘密による認証ではありません。目的は (a) プロジェクト識別、(b) 無差別 spam の抑止、(c) ローテーションによる失効。レビュアー個人の認証(デモ側ログイン前提の署名付き token)は将来スコープとして README の境界に明記しました。
変更内容
receiver
INGEST_KEYSenv(カンマ区切り)/ configingestKeys(配列)。設定時はX-PatchLoop-Ingest-Keyヘッダーの一致(timing-safe)を必須にし、欠落・不一致は 401。未設定は従来通りオープン(ゼロ設定互換)ingestとして宣言(PR-1 のコメントで予告していた拡張)。dispatch が一元適用し、解決した key entry を handler に渡す{ "key": "...", "projectId": "..." }形式で key ↔ projectId の紐付け: 紐付き key での投稿は payload のprojectId詐称を 403 で拒否、省略時は補完(store 上のレコードに必ず帰属が付く)Access-Control-Allow-Headersに key ヘッダーを追加(Issue の設計メモ: 忘れると preflight で widget 送信が全滅)ingest auth: enabled (N keys) / openを出力(キー値は出さない)widget
ingestKeyを追加し、receiver POST にヘッダーで送信(dist 再ビルド込み)docs
INGEST_KEYSを推奨手順に追加)/ 「現在の境界」の更新テスト
npm run check全 105 件パス(新規 2 件: キー必須・誤キー拒否・preflight ヘッダー・/import 非干渉 / projectId 紐付けの一致・詐称 403・補完)。実機スモーク済み: 起動ログ / no key 401 / wrong key 401 / 素キー 201 / 紐付き key + 詐称 projectId 403 / 省略時補完(store で確認)/ preflight Allow-Headers / dist へのヘッダー反映。Closes #44
🤖 Generated with Claude Code
https://claude.ai/code/session_01LRdDjwxbAAaTMwwnzipkau