MPP: credential is always sent in Authorization, ignoring header="Payment-Authorization" in the challenge

オープン 初心者向け
#702 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@abhiramshaji-cyber がすでに取り組んでいます。

2026年10月27日 から。

  • #719 @abhiramshaji-cyber による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
api, backend

調査の方向性

bedrock_agentcore/payments/manager.py の PaymentManager._generate_mpp_payment_header から調査を始め、選択された challenge header が generate_payment_header にどのように渡されるかを追ってください。Strands handler と LangGraph middleware が返された header をどのように適用するかを確認し、Payment-Authorization と Authorization のデフォルト動作の両方について、対象を絞ったテストを追加するか実行してください。選択された header に認証情報が含まれ、呼び出し元に既存の Authorization 値がある場合はそれが保持されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug

Describe the bug

The MPP core spec lets a challenge choose the request header for the credential. With header="Payment-Authorization", the client must send the credential in Payment-Authorization, so that Authorization stays free for the client's own authentication (draft-httpauth-payment-01, section "Credentials"). The server accepts the credential only from the selected field, and a client that does not support Payment-Authorization must not send a credential for such a challenge.

PaymentManager._generate_mpp_payment_header always returns {"Authorization": "Payment <credential>"}, whatever the selected challenge says. For a challenge with header="Payment-Authorization", the SDK:

  • pays it (ProcessPayment is called);
  • returns the credential under Authorization, where the server does not look for it;
  • replaces the caller's own Authorization value (for example a Bearer token) when the Strands plugin or the LangGraph middleware applies the header to the retried request (apply_payment_header updates the headers dict).

mppx servers send this parameter when created with Mppx.create({ requiresAuth: true, ... }) (added in mppx 0.9.0), and then read the credential only from Payment-Authorization.

To Reproduce

bedrock-agentcore 1.24.1 (main at b70e0b7), Python 3.10:

import base64
import json
from unittest.mock import MagicMock, patch

from bedrock_agentcore.payments.integrations.handlers import GenericPaymentHandler
from bedrock_agentcore.payments.manager import PaymentManager

request = {
    "amount": "1000",
    "currency": "0x036CbD53842c5426634e7929541eC2318f3dCF71",
    "recipient": "0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00",
    "methodDetails": {"chainId": 84532},
}
encoded = base64.urlsafe_b64encode(json.dumps(request, separators=(",", ":")).encode()).decode().rstrip("=")
challenge = (
    f'Payment id="x7Tg2pLqR9mKvNwY3hBcZa", realm="api.example.com", method="evm", intent="charge", '
    f'header="Payment-Authorization", request="{encoded}"'
)

with patch("boto3.Session") as session:
    session.return_value.region_name = "us-west-2"
    manager = PaymentManager(
        payment_manager_arn="arn:aws:bedrock-agentcore:us-west-2:123456789012:payment-manager/pm-abc123",
        region_name="us-west-2",
    )
manager._payment_client = MagicMock()
manager._payment_client.get_payment_instrument.return_value = {
    "paymentInstrument": {"paymentInstrumentDetails": {"embeddedCryptoWallet": {"network": "ETHEREUM"}}}
}
manager._payment_client.process_payment.return_value = {
    "processPayment": {
        "status": "PROOF_GENERATED",
        "paymentOutput": {"mpp": {"selectedPaymentId": "x7Tg2pLqR9mKvNwY3hBcZa", "paymentCredential": "eyJ0b2tlbiI6MX0"}},
    }
}

payment_header = manager.generate_payment_header(
    user_id="user-1",
    payment_instrument_id="pi-1",
    payment_session_id="ps-1",
    payment_required_request={"statusCode": 402, "headers": {"WWW-Authenticate": challenge}, "body": {}},
)
print("ProcessPayment calls:", manager._payment_client.process_payment.call_count)
print("payment header:", payment_header)

tool_input = {"url": "https://api.example.com/resource", "headers": {"Authorization": "Bearer mF_9.B5f-4.1JqM"}}
GenericPaymentHandler().apply_payment_header(tool_input, payment_header)
print("retried request headers:", tool_input["headers"])

Output:

ProcessPayment calls: 1
payment header: {'Authorization': 'Payment eyJ0b2tlbiI6MX0'}
retried request headers: {'Authorization': 'Payment eyJ0b2tlbiI6MX0'}

Expected behavior

For a challenge with header="Payment-Authorization", generate_payment_header returns {"Payment-Authorization": "Payment <credential>"}, and the retried request keeps its own Authorization header. A challenge without header keeps using Authorization, as now. Until the field is supported, such a challenge should not be selected or paid.

Additional context

  • The parameter was added to the spec in tempoxyz/mpp-specs#328 (2026-08-25), a week after MPP support landed here in #643 (2026-08-18).
  • The spec also asks the client to echo header in the credential's challenge object. The raw challenge, including header, is already forwarded to ProcessPayment, so that part may be handled by the service; I could not check it.
主要言語
Python
スター
786
フォーク
163
平均マージ
4時間
マージ済み PR(30日)
22

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aws/bedrock-agentcore-sdk-python のほかの issue

aws/bedrock-agentcore-sdk-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。