Repository navigation
feat: fetch response headers, Accept-Language, and ResourceClient.UseDPoPNonce - #691
Merged
Merged
Conversation
…nguage FetchResponse had only the body and status code, so a caller couldn't read a header a server sends with its answer without bypassing fapihttp's hardening: the DPoP-Nonce an OpenID4VCI Nonce Response carries (OpenID4VCI 1.0 §7.2, RFC 9449 §8), say. FetchResponse.Header now holds the response's header fields, the final response's after any redirects, as a copy. FetchRequest and PostRequest gain AcceptLanguage, sent as the Accept-Language header (RFC 9110 §12.5.4): OpenID4VCI 1.0 §12.2.2 recommends a Wallet send it when fetching Credential Issuer Metadata, so display metadata comes in the user's language. It follows Accept's rules (printable ASCII, at most 1024 bytes). It's a named field rather than a header map: the headers fapihttp sends, and the absence of the rest (cookies, credentials), are part of what it hardens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OpenID4VCI 1.0 §7.2 lets a Credential Issuer's Nonce Response carry a DPoP nonce in its DPoP-Nonce header, which "the Wallet uses ... when presenting an access token at the Credential Endpoint". The Nonce Endpoint isn't called through ResourceClient, so its nonce never reached Do, whose first request was challenged with use_dpop_nonce. Seeding the nonce cache by hand meant copying its unexported key format. UseDPoPNonce has the next Do to a resource's origin present a nonce it was given, through the nonce cache every client has had since it became the default. A wrong or stale nonce costs only the challenge and retry Do already handles. It does nothing under SenderConstrainMTLS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
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.



Lets a wallet use the DPoP nonce an OpenID4VCI Nonce Response carries, and ask for issuer metadata in the user's language. Both changes are additive; nothing breaks.
Why
DPoP nonce. OpenID4VCI 1.0 §7.2 lets the Credential Issuer's Nonce Response carry a
DPoP-Nonceheader, which "the Wallet uses ... when presenting an access token at the Credential Endpoint". A FAPIgo-based wallet couldn't do that, for two reasons:fapihttpnever returned response headers, so the only way to read one was to bypass its hardening.ResourceClienthad no way to take a nonce it was handed elsewhere: seeding its cache meant copying the unexported key format.So the first Credential Request was always challenged with
use_dpop_nonceand retried.Accept-Language. OpenID4VCI 1.0 §12.2.2 recommends sending
Accept-Languageon the issuer-metadata request, so display metadata comes in the user's language.fapihttphad no way to send it.Changes
fapihttp.FetchResponse.Header: the response's header fields, the final response's after any redirects, as a copy. Filled by bothFetchandPost.FetchRequest.AcceptLanguageandPostRequest.AcceptLanguage: sent asAccept-Language(RFC 9110 §12.5.4), underAccept's rules: printable ASCII, at most 1024 bytes.fapihttpsends, and the absence of the rest (cookies, credentials), are part of what it hardens.client.ResourceClient.UseDPoPNonce(ctx, resource, nonce): the nextDoto that origin presents the nonce.Doalready handles. The nonce is a hint, not a credential.Testing
fapihttp:Accept-Languageis sent on every redirect hop and on a POST;Headerholds the final response's headers, as a copy;Accept-Languagewith CRLF, or over 1024 bytes, is refused before any request.client: afterUseDPoPNonce, the firstDopresents the nonce and isn't challenged; a stale one gets one challenge and a retry.go vet,go test ./..., andgo test -raceon Go 1.26.9 forfapihttpandclient;🤖 Generated with Claude Code