-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add enableDPoP
flag for Hosted Buttons
#2340
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2340 +/- ##
=======================================
Coverage 51.58% 51.58%
=======================================
Files 105 105
Lines 2055 2055
Branches 616 616
=======================================
Hits 1060 1060
Misses 892 892
Partials 103 103
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Description
This PR adds a new prop
enableDPoP
to the hosted buttons component to feature-flag adding DPoP headers to/v1/oauth2/token
and protected resource requests.When
enableDPoP
istrue
, requests to create an access token will include aDPoP
header (see https://datatracker.ietf.org/doc/html/rfc9449#name-dpop-access-token-request) that includes information about the request (request method and uri) and information about the device (the in-memory public key generated from the buyer's browser) and signed with an in-memory and non-extractable private key.When
enableDPoP
istrue
, requests to protected resources will replace the existingAuthorization: Bearer <token>
with the new authentication scheme:Authorization: DPoP <token>
and also include aDPoP
header. (see https://datatracker.ietf.org/doc/html/rfc9449#name-protected-resource-access).When
enableDPoP
isfalse
(orundefined
), no existing functionality is changed. This property is used as a feature flag only before general availability.Why are we making these changes?
The hosted buttons component creates access tokens cross-origin from the merchant's site. DPoP enforces a policy where access tokens can only be used from the device that requested the access token.
From https://datatracker.ietf.org/doc/html/rfc9449#name-objectives:
Reproduction Steps
add
enableDPoP: true
topaypal.HostedButtons({})
Screenshots
See an example DPoP proof (and its contents) validated in the jwt.io debugger .
I also wanted to include the above link to show that no sensitive information is included in the
DPoP
proof. Even when an access token is passed tobuildDPoPHeaders
, it is hashed (ath).Dependent Changes
Everything related to JWT creation, key pair generation, and signatures is implemented in
@paypal/sdk-client
:Future PRs:
Groups who should review (if applicable)
❤️ Thank you!