fix(middleware): read body-layer credentials from the verifier header - #419
Merged
Merged
Conversation
PaymentService reads the credential from `verifier.credential_header()` (added in tempoxyz#400 so `requires_auth` servers can keep `Authorization` for their own auth), but PaymentBodyService still hard-coded `Authorization`. A `PaymentBodyLayer` over an `Mpp` with `requires_auth(true)` issues challenges advertising `header="Payment-Authorization"`, then never looks at that header, so a conforming client is answered with a fresh 402 on every retry. Use the verifier's header in the body layer as well.
kriss39
requested review from
brendanjryan,
mattsse and
onbjerg
as code owners
September 13, 2026 06:45
Contributor
Author
|
@brendanjryan gentle ping on this one when you have time. |
mattsse
enabled auto-merge (squash)
September 30, 2026 13:33
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.
#400 added
PaymentVerifier::credential_header()and madePaymentServiceread the credential from it, so anMppbuilt withrequires_auth(true)advertisesheader="Payment-Authorization"and leavesAuthorizationto the application.PaymentBodyService::callwas not updated and still readsheader::AUTHORIZATION.With
PaymentBodyLayer::charge(&mpp, ..)on such anMpp, a client that follows the challenge and sendsPayment-Authorization: Payment …(with its ownAuthorization: Bearer …) gets a fresh 402 back on every attempt: the layer never sees the credential, andextract_payment_schemeon the bearer token yieldsNone. Body-bound payments are simply unverifiable in that configuration.One-line fix (
get(verifier.credential_header()), matchingPaymentService), plus two tests using a body-aware verifier that returnsPayment-Authorization: a credential in the advertised header verifies and replays the body, and a credential left inAuthorizationis ignored, as it already is inPaymentService. Both fail onmain.