Skip to content

Knowledge Base のメタデータフィルタリングに、ABAC(属性ベースアクセス制御)および S3 プレフィックスベースのドキュメントアクセス制御の動的フィルター例を追加します。#1457

Open
takke1986 wants to merge 1 commit intoaws-samples:mainfrom
takke1986:feat/abac-metadata-filter

Conversation

@takke1986
Copy link
Contributor

@takke1986 takke1986 commented Feb 13, 2026

変更内容
フィルター例の追加:

Example 3: ABAC フィルター — Cognito カスタム属性(custom:department)を使用し、equals オペレーターでユーザーの所属部署に一致するドキュメントのみを検索対象にするフィルター例。全ベクトルストアで利用可能。
Example 4: S3 プレフィックスフィルター — x-amz-bedrock-kb-source-uri と startsWith オペレーターを使用し、S3 オブジェクトのプレフィックスに基づいて検索結果を制限するフィルター例。startsWith は S3 Vectors ベクトルストアでは非対応のため、OpenSearch Serverless 等でのみ利用可能。

インフラ・設定変更:

Chat Lambda に DATA_SOURCE_BUCKET_NAME 環境変数を追加(S3 プレフィックスフィルター用)
サンプル metadata.json ファイルに department キーを追加

ドキュメント更新:

日本語・英語の DEPLOY_OPTION.md に ABAC および S3 プレフィックスフィルターのセットアップ手順を追記
Claude Sonnet 3.5 に関する注記を dynamicFilters から implicitFilters の説明に移動(本来の適切な位置へ)

セキュリティに関する注記
ABAC フィルター(Example 3)を部署間のアクセス制御として使用する場合、以下の前提条件が必要です。ドキュメントにもこの旨を記載しています。

フィルター値の取得元: custom:department の値は必ずサーバーサイドで Cognito トークンのクレームから取得し、クライアントからのリクエストパラメータは使用しないこと
カスタム属性の編集権限: Cognito ユーザープールの custom:department 属性はユーザー自身が編集できない(管理者のみ変更可能な)設定にすること
メタデータファイルの保護: データソース S3 バケットの .metadata.json ファイルにエンドユーザーが直接書き込みできないように IAM ポリシーで制限すること。ユーザーがドキュメントをアップロードする要件がある場合は、アップロード用の一時バケットを経由し、Lambda 等でメタデータを認証情報に基づいて自動付与する構成とすること

既存ユーザーへの影響

既存の Example 1(Cognito Groups)、Example 2(SAML IdP Groups)には影響なし
DATA_SOURCE_BUCKET_NAME 環境変数は Example 4 を使用する場合のみ必要。未設定でも既存動作に影響なし
implicitFilters への注記移動は表示上の変更のみで、動作への影響なし

Checklist

  • Modified relevant documentation
  • Verified operation in local environment
  • Executed npm run cdk:test and if there are snapshot differences, execute npm run cdk:test:update-snapshot to update snapshots

Related Issues
#1456

…dge Base

Add dynamic filter examples for ABAC (Attribute-Based Access Control)
and S3 prefix-based document access control in Knowledge Base metadata
filtering.

Changes:
- Add Example 3: ABAC filter using Cognito custom attributes
  (e.g., custom:department) with equals operator
- Add Example 4: S3 prefix filter using x-amz-bedrock-kb-source-uri
  with startsWith operator (OpenSearch Serverless only)
- Pass DATA_SOURCE_BUCKET_NAME env var to chat Lambda for prefix filter
- Add department key to sample metadata.json files
- Add ABAC and S3 prefix filter documentation in ja/en DEPLOY_OPTION.md
- Move Claude Sonnet 3.5 note to implicitFilters where it belongs

Co-authored-by: Cursor <cursoragent@cursor.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.

1 participant