Repository navigation
feat(resource): build a VerifyRequest from an http.Request - #504
Merged
Merged
Conversation
resource.VerifyRequestFromHTTP(r, target) fills in every field of the VerifyRequest for a request to the protected resource at target: the method, the Authorization header, every DPoP header, and the TLS client certificate. Filling the struct by hand compiles with a field left out, and then fails only for the clients that need it. Four of the demos left out PeerCertificate, which refuses every mTLS-bound token, and payroll-run left out DPoPProofs. The server's own FromHTTP constructors exist for the same reason. target stays the caller's: this endpoint's fixed external URL, never one built from the request's Host header. It is copied, never modified. The five demos, cmd/conformance-as and GETTING_STARTED now use it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
osanderson
force-pushed
the
feat/resource-verify-request-from-http
branch
from
October 2, 2026 04:15
b15b18c to
d0dfec4
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 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.



Summary
This is the first library addition from the DevX review.
It fills in every field of the
VerifyRequestforr:Method;Authorizationheader;DPoPheader (DPoPProofsFromHTTP, soVerifycan still refuse more than one);PeerCertificateFromHTTP).Why. Seven call sites built the struct by hand. Leaving a field out still compiles, and then fails only for the clients that need it:
PeerCertificate, which refuses every mTLS-bound token;DPoPProofs;GETTING_STARTEDhad the same gap until docs: cover v0.42.0's features and add an examples overview #494.The server's
PushAuthorizationRequestFromHTTPandTokenEndpointRequestFromHTTPexist for exactly this reason;resourcehad the parts but not the whole.The URL stays the caller's.
targetis this endpoint's own fixed external URL (what a DPoP proof'shtunames), never one built fromr.Host, which the client controls. For a route with path parameters, the doc says to copy a fixed origin and setPathfromr.URL.Path, as decoupled-checkout does.targetis copied, never aliased.Adopted:
cmd/conformance-as's UserInfo and accounts handlers;GETTING_STARTED's resource-server step, whose prose now explains what the constructor fills in and what it leaves to the caller.Tests
DPoPheaders kept in order.target.go test -race ./...and golangci-lint pass;cmd/conformance-aspass their tests and lint;GETTING_STARTED's snippets still compile.🤖 Generated with Claude Code