feat(pro-326): forward client IP to origin via CLIENT_IP_HEADER config - #4
Open
alistairsmith-tech wants to merge 1 commit into
Open
alistairsmith-tech wants to merge 1 commit into
alistairsmith-tech wants to merge 1 commit into
Conversation
When the CLIENT_IP_HEADER Config Store key is set (written live by the web deploy flow), proxyToOrigin stamps the visitor IP under that header name alongside the existing X-Forwarded-For / Fastly-Client-IP handling, now extracted into setClientIpHeaders. Same edge-trust-boundary rules: always overwritten, stripped when no client IP is available, so an inbound client-supplied value can never reach the origin as a spoofed identity. No behavior change when the key is absent. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Plugin half of the SFCC client-IP header feature (PRO-326, part of the PRO-316 stacked-CDN work; web's
writeServiceConfigalready upserts/deletes aCLIENT_IP_HEADERConfig Store key that current packages ignore).src/clientIp.tsextracts the origin client-IP header stamping fromproxyToOrigininto a pure, tested helper coveringX-Forwarded-For,Fastly-Client-IP, and now the optional configured custom header (e.g. Salesforce Commerce Cloud's Client IP Header Name).event.client.address, strip when no client IP is available, never pass an inbound value through.Tests
New
test/clientIp.test.ts: overwrite of standard headers, overwrite of a forged custom header, strip-all when no IP, and pass-through of an unknown header when unconfigured. Full suite: 43/43 passing.Release notes
After merge: tag a release, bump
MONOCLE_FASTLY_PACKAGE_VERSIONin web, redeploy SFCC apps.🤖 Generated with Claude Code