feat: PR 1.7 Add DPoP (Demonstrating Proof-of-Possession) support #363
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.
📝 Checklist
🔧 Changes
This PR implements RFC 9449 DPoP (Demonstrating Proof-of-Possession) support for sender-constrained OAuth 2.0 tokens, providing enhanced security by binding tokens to cryptographic key pairs.
Core Package Changes:
Validatorinterface supporting both JWT and DPoP validation methodsCheckTokenWithDPoPmethod incore.Corefor framework-agnostic validationDPoPDisabled,DPoPIfPresent(default),DPoPRequiredErrorCodeDPoPProofMissing,ErrorCodeDPoPProofInvalid,ErrorCodeDPoPBindingMismatchMiddleware Changes:
WithDPoPMode,WithDPoPProofOffset,WithDPoPIATLeeway,WithDPoPHeaderExtractorWithTrustedProxiesfor URL reconstruction behind reverse proxiesValidator Package:
ValidateDPoPProofmethod toValidatorstructNew Files:
core/dpop.go- Core DPoP validation logicdpop.go- HTTP middleware DPoP helpersproxy.go- Trusted proxy URL reconstructionvalidator/dpop.go- DPoP proof validationvalidator/dpop_claims.go- DPoP claims interfaceExamples:
examples/http-dpop-example- Full DPoP implementation with optional Bearer fallbackexamples/http-dpop-required- Strict DPoP enforcement modeexamples/http-dpop-disabled- Explicit DPoP opt-out for legacy systemsexamples/http-dpop-trusted-proxy- Production deployment behind reverse proxiesBreaking Changes: None - fully backward compatible with existing Bearer token implementations. DPoP is opt-in via token scheme or explicit mode configuration.
📚 References
🔬 Testing
Test Coverage:
Manual Testing:
All example applications include integration tests demonstrating:
Verification: