-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add DPoP sender-constrained token support (RFC 9449) #109
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -255,6 +255,32 @@ print_r($response); | |
| 6. `DescopeSDK->getClaims($sessionToken)` - will return all of the claims from the JWT in an array format. | ||
| 7. `DescopeSDK->getUserDetails($refreshToken)` - will return all of the user information (email, phone, verification status, etc.) using a provided refresh token. | ||
|
|
||
| ### DPoP Sender-Constrained Tokens (RFC 9449) | ||
|
|
||
| When a Descope session token contains a `cnf.jkt` claim it is DPoP-bound, meaning every request must include a signed `DPoP` proof JWT that demonstrates possession of the corresponding private key. | ||
|
|
||
| Use `validateDPoP` **after** a successful `verify` call to enforce the sender-constraint: | ||
|
|
||
| ```php | ||
| // 1. Verify the session token as usual | ||
| $descopeSDK->verify($sessionToken); | ||
|
|
||
| // 2. If the token is DPoP-bound, validate the DPoP proof | ||
| // (does nothing if the token has no cnf.jkt claim) | ||
| $descopeSDK->validateDPoP( | ||
| $sessionToken, // the verified session JWT | ||
| $_SERVER['HTTP_DPOP'] ?? '', // DPoP header sent by the client (empty string if absent) | ||
| $_SERVER['REQUEST_METHOD'], // e.g. "GET" or "POST" | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. Changed
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. Changed to |
||
| 'https://example.com/api/resource' // full request URL | ||
| ); | ||
| ``` | ||
|
|
||
| `validateDPoP` throws `\Descope\SDK\Exception\TokenException` if: | ||
|
|
||
| - The session token is DPoP-bound but no proof is provided. | ||
| - The proof signature, `htm` (method), `htu` (URL), `iat` (timestamp), or `ath` (access token hash) is invalid. | ||
| - The proof key does not match the `cnf.jkt` thumbprint in the session token. | ||
|
|
||
| ### User Management Functions | ||
|
|
||
| Each of these functions have code examples on how to use them. | ||
|
|
||
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.
🟢 LOW:
$_SERVER['HTTP_DPOP']is unset when the client doesn't send a DPoP header. PassingnullintovalidateDPoP(string $dpopProof, ...)raisesTypeErrorrather than the intended\Exception('DPoP proof required...').Suggest showing the safe form so users don't copy a snippet that crashes on the very case the function is designed to detect: