Skip to content

Conversation

@tusharpandey13
Copy link
Contributor

@tusharpandey13 tusharpandey13 commented Oct 30, 2025

The auth code callback flow was missing the DPoP nonce retry pattern that already exists for:

  • Refresh token requests (refreshTokenGrantRequest)
  • Connection token exchanges (genericTokenEndpointRequest)

When a server requires a DPoP nonce, it responds with HTTP 400 + use_dpop_nonce error + DPoP-Nonce header. The client must retry with the provided nonce. Without this retry logic, the error propagates to the user and login fails.
endpoint flows.

Changes

Wrapped the authorizationCodeGrantRequestCall with withDPoPNonceRetry() when DPoP is enabled, matching the existing patterns for other token.

  • src/server/auth-client.ts (lines 784-789): Added conditional DPoP nonce retry wrapper in handleCallback() method
  • src/server/dpop-authcode-nonce-retry.test.ts: Added MSW-based HTTP flow tests validating:
    • First request without nonce receives 400 + use_dpop_nonce error
    • Automatic retry with server-provided nonce succeeds
    • Second request returns 200 + valid tokens
  • dpopUtils.ts: handle both type of request retries

References

  • RFC 9449

Addendum

Replaces #2390 with all review comments addressed

@tusharpandey13 tusharpandey13 requested a review from a team as a code owner October 30, 2025 15:06
@tusharpandey13 tusharpandey13 changed the title DPoP nonce retry on auth code callback fix: DPoP nonce retry on auth code callback Oct 30, 2025
@tusharpandey13 tusharpandey13 merged commit 2c71793 into main Oct 30, 2025
26 of 27 checks passed
@tusharpandey13 tusharpandey13 deleted the bugfix/dpop-retry-authcode branch October 30, 2025 15:36
@tusharpandey13 tusharpandey13 mentioned this pull request Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants