Skip to content

feat(pro-326): forward client IP to origin via CLIENT_IP_HEADER config - #4

Open
alistairsmith-tech wants to merge 1 commit into
mainfrom
feat/pro-326
Open

alistairsmith-tech wants to merge 1 commit into
mainfrom
feat/pro-326

Conversation

@alistairsmith-tech

Copy link
Copy Markdown
Collaborator

Summary

Plugin half of the SFCC client-IP header feature (PRO-326, part of the PRO-316 stacked-CDN work; web's writeServiceConfig already upserts/deletes a CLIENT_IP_HEADER Config Store key that current packages ignore).

  • New src/clientIp.ts extracts the origin client-IP header stamping from proxyToOrigin into a pure, tested helper covering X-Forwarded-For, Fastly-Client-IP, and now the optional configured custom header (e.g. Salesforce Commerce Cloud's Client IP Header Name).
  • Anti-spoofing invariant (unchanged semantics, now extended to the custom header): always overwrite from event.client.address, strip when no client IP is available, never pass an inbound value through.
  • Config value is read live from the Config Store, so the header name can change without a package redeploy. No behavior change when the key is absent.

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_VERSION in web, redeploy SFCC apps.

🤖 Generated with Claude Code

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>
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.

1 participant