Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/changelog/3119-from-description
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add DPoP (RFC 9449) support to protect OAuth tokens from theft and replay.
15 changes: 9 additions & 6 deletions includes/oauth/class-authorization-code.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,14 @@ public static function create(
/**
* Exchange authorization code for tokens.
*
* @param string $code The authorization code.
* @param string $client_id The client ID.
* @param string $redirect_uri The redirect URI (must match original).
* @param string $code_verifier The PKCE code verifier.
* @param string $code The authorization code.
* @param string $client_id The client ID.
* @param string $redirect_uri The redirect URI (must match original).
* @param string $code_verifier The PKCE code verifier.
* @param string|null $dpop_jkt Optional DPoP JWK thumbprint for token binding.
* @return array|\WP_Error Token data or error.
*/
public static function exchange( $code, $client_id, $redirect_uri, $code_verifier ) {
public static function exchange( $code, $client_id, $redirect_uri, $code_verifier, $dpop_jkt = null ) {
$redirect_uri = Sanitize::redirect_uri( $redirect_uri );
$code_hash = self::hash_code( $code );
$transient = self::TRANSIENT_PREFIX . $code_hash;
Expand Down Expand Up @@ -195,7 +196,9 @@ public static function exchange( $code, $client_id, $redirect_uri, $code_verifie
return Token::create(
$code_data['user_id'],
$client_id,
$code_data['scopes']
$code_data['scopes'],
Token::DEFAULT_EXPIRATION,
$dpop_jkt
);
}

Expand Down
Loading
Loading