Skip to content

feat: forward X-BitGo-OTP header from client requests to BitGo API#8493

Merged
sandra-wang-bitgo merged 1 commit intomasterfrom
claude/review-header-whitelist-JB0UY
Apr 14, 2026
Merged

feat: forward X-BitGo-OTP header from client requests to BitGo API#8493
sandra-wang-bitgo merged 1 commit intomasterfrom
claude/review-header-whitelist-JB0UY

Conversation

@sandra-wang-bitgo
Copy link
Copy Markdown
Contributor

@sandra-wang-bitgo sandra-wang-bitgo commented Apr 13, 2026

Description

This change adds support for forwarding the X-BitGo-OTP header from incoming client requests to the BitGo API. This enables clients to pass OTP (One-Time Password) credentials through the Express proxy to the backend BitGo service.

The implementation introduces a configurable FORWARDED_HEADERS list that specifies which headers should be forwarded from incoming requests to the BitGo API. Currently, only x-bitgo-otp is included, but the design allows for easy addition of other headers in the future.

Changes Made:

  • Added FORWARDED_HEADERS constant to define which headers should be forwarded
  • Updated redirectRequest() function to iterate through forwarded headers and set them on outgoing requests
  • Added proper handling for both string and array header values (Express can normalize headers to arrays)
  • Added unit tests to verify the header is forwarded when present and not forwarded when absent

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Added two new unit tests in modules/express/test/unit/clientRoutes/index.ts:

  1. should forward X-BitGo-OTP header when present - Verifies the header is correctly forwarded to the BitGo API when included in the incoming request
  2. should not forward X-BitGo-OTP header when not present - Verifies the code handles the absence of the header gracefully

Both tests verify the behavior through stubbed responses and assertion on the set() method calls.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my feature works
  • New and existing unit tests pass locally with my changes

TICKET: CUS-80

@sandra-wang-bitgo sandra-wang-bitgo requested review from a team as code owners April 13, 2026 16:03
@sandra-wang-bitgo sandra-wang-bitgo marked this pull request as draft April 13, 2026 16:10
@sandra-wang-bitgo sandra-wang-bitgo changed the title Forward X-BitGo-OTP header from client requests to BitGo API feat: forward X-BitGo-OTP header from client requests to BitGo API Apr 13, 2026
@sandra-wang-bitgo sandra-wang-bitgo force-pushed the claude/review-header-whitelist-JB0UY branch 3 times, most recently from e2d43b5 to 2a48eb4 Compare April 13, 2026 17:11
The redirectRequest function was not forwarding any client headers to
the BitGo API, which meant the X-BitGo-OTP header (used for 2FA) was
being silently dropped. Add a FORWARDED_HEADERS whitelist and forward
matching headers from incoming requests.

Ticket: CS-7494
@sandra-wang-bitgo sandra-wang-bitgo force-pushed the claude/review-header-whitelist-JB0UY branch 2 times, most recently from 293d340 to 7b1ab98 Compare April 13, 2026 17:16
@sandra-wang-bitgo sandra-wang-bitgo marked this pull request as ready for review April 13, 2026 17:33
@sandra-wang-bitgo sandra-wang-bitgo merged commit 531d4f6 into master Apr 14, 2026
21 checks passed
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.

2 participants