Skip to content

Add HttpOnly session cookies for SLAS private client proxy#3679

Closed
unandyala wants to merge 14 commits intodevelopfrom
feature/httponly-session-cookies
Closed

Add HttpOnly session cookies for SLAS private client proxy#3679
unandyala wants to merge 14 commits intodevelopfrom
feature/httponly-session-cookies

Conversation

@unandyala
Copy link
Contributor

Summary

  • When MRT_DISABLE_HTTPONLY_SESSION_COOKIES is 'false', SLAS token responses are intercepted by the proxy: access_token, refresh_token, and idp_access_token are set as HttpOnly cookies (with siteId suffix) and stripped from the response body
  • Client receives access_token_expires_at in the response body for expiry checks without needing the JWT
  • Proxy reads access token from HttpOnly cookies and sets Authorization: Bearer header for SCAPI requests automatically via applyProxyRequestAuthHeader()
  • New useHttpOnlySessionCookies flag on Auth and CommerceApiProvider controls client-side behavior: skips storing tokens in localStorage, uses access_token_expires_at for expiry checks, and ensures fetch credentials allow cookies
  • Configurable tokenResponseEndpoints and slasEndpointsRequiringAccessToken regexes allow customization in ssr.js

Follow-up work

  • TAOB (Trusted Agent on Behalf) flow with HttpOnly cookies
  • Refresh token flow with HttpOnly cookies (server-side proxy extraction of refresh token from cookie)

Test plan

  • Verify HttpOnly cookies are set on token responses when MRT_DISABLE_HTTPONLY_SESSION_COOKIES=false
  • Verify tokens are stripped from response body and access_token_expires_at is present
  • Verify SCAPI proxy requests include Authorization: Bearer header from cookie
  • Verify feature is disabled when MRT_DISABLE_HTTPONLY_SESSION_COOKIES is not 'false'
  • Verify non-token endpoints (e.g., logout) are not processed for HttpOnly cookies
  • Verify client-side expiry checks work via access_token_expires_at
  • Run existing unit tests (npm test in pwa-kit-runtime and commerce-sdk-react)

🤖 Generated with Claude Code

unandyala and others added 14 commits February 5, 2026 18:36
…es (#3635)

* Add config flag to enable httponly session cookies
* One click checkout

* changes to fix install, tests and lint - needs to be reviewed

* revert the test change in pwa-kit-runtime

* @W-20892497 Show Phone number in Contact Info summary (#3576)

* W-20892497 Show Phone number in Contact Info summary

* fix lint

* @W-20892592 Remove gift messaging for multi shipment (#3579)

* W-20892592 Remove gift messaging for multi shipment

* translations

* @W-20892530 @W-20892577 Billing Address Validation and Using contact phone for user registration (#3583)

* W-20892530 Billing Address Validation

* W-20892577 save contact info phone

* Fix SDK tests (#3593)

* fix sdk tests and app bundle size

* fix lint

* @ W-20540715 Address 1CC feature branch review comments (#3619)

* address first set of comments

* address rest of code review comments

* reverting default.js changes

* fix package versions

* shipping options fix

* attempt to fix flaky tests

* passwordless mode updates

* @W-21094171: Fix Resend Code for OTP modal

Signed-off-by: d.phan <d.phan@salesforce.com>

* add translations

Signed-off-by: d.phan <d.phan@salesforce.com>

* fix lint

Signed-off-by: d.phan <d.phan@salesforce.com>

* update component per UX alignment

Signed-off-by: d.phan <d.phan@salesforce.com>

* no actions during verification

Signed-off-by: d.phan <d.phan@salesforce.com>

* revert to generic error message as per code review comment

* transaltion changes

* fix the rebase issue

* update isomorphic version

* update isomorhic in dev dependencies

* Updating another dev dependency for isomorphic version

* @W-21094171: Fix Resend Code for OTP modal

Signed-off-by: d.phan <d.phan@salesforce.com>

* fix package versions

---------

Signed-off-by: d.phan <d.phan@salesforce.com>
Co-authored-by: Sushma Yadupathi <syadupathi@salesforce.com>
Co-authored-by: syadupathi-sf <66088780+syadupathi-sf@users.noreply.github.com>
#3639)

* Default to ECOM Shipping when OMS does not return shipping

* Add changelog

* lint fix

* nit optional check

* variable rename
…leware, test query strings are preserved, resolved path does not include base path, and base path exists in environment
* @W-21109850: Continue as Guest skips entering phone number (#3626)

* One click checkout

* changes to fix install, tests and lint - needs to be reviewed

* revert the test change in pwa-kit-runtime

* @W-20892497 Show Phone number in Contact Info summary (#3576)

* W-20892497 Show Phone number in Contact Info summary

* fix lint

* @W-20892592 Remove gift messaging for multi shipment (#3579)

* W-20892592 Remove gift messaging for multi shipment

* translations

* @W-20892530 @W-20892577 Billing Address Validation and Using contact phone for user registration (#3583)

* W-20892530 Billing Address Validation

* W-20892577 save contact info phone

* Fix SDK tests (#3593)

* fix sdk tests and app bundle size

* fix lint

* @ W-20540715 Address 1CC feature branch review comments (#3619)

* address first set of comments

* address rest of code review comments

* reverting default.js changes

* fix package versions

* shipping options fix

* attempt to fix flaky tests

* passwordless mode updates

* @W-21109850: Continue as Guest skips entering phone number

Signed-off-by: d.phan <d.phan@salesforce.com>

* fix import

Signed-off-by: d.phan <d.phan@salesforce.com>

* translations

* fix user not found error

---------

Signed-off-by: d.phan <d.phan@salesforce.com>
Co-authored-by: Sushma Yadupathi <syadupathi@salesforce.com>
Co-authored-by: syadupathi-sf <66088780+syadupathi-sf@users.noreply.github.com>

* W-21111863 Hide user registration for returning shoppers who chose to checkout as guest (#3634)

* @W-21005976 Save newly registered user's info when they leave checkout… (#3632)

* W-21005976 Save newly registered user's info when they leave checkout and return

* code review comments

* @W-21109829 Editing shipping options in multi shipment scenarios (#3637)

* W-21109829 Editing shipping options in multi shipment scenarios

* minor text changes

* remove unnecessary test

---------

Signed-off-by: d.phan <d.phan@salesforce.com>
Signed-off-by: syadupathi-sf <66088780+syadupathi-sf@users.noreply.github.com>
Co-authored-by: Danny Phan <125327707+dannyphan2000@users.noreply.github.com>
* Update button alignment in OtpAuth component to center for improved UX
When MRT_DISABLE_HTTPONLY_SESSION_COOKIES is 'false', token responses from
SLAS are intercepted: access_token, refresh_token, and idp_access_token are
set as HttpOnly cookies and stripped from the response body. The client
receives access_token_expires_at for expiry checks without needing the JWT.

Server-side (pwa-kit-runtime):
- applyHttpOnlySessionCookies() intercepts token responses, sets HttpOnly
  cookies with siteId suffix, and strips tokens from body
- applyProxyRequestAuthHeader() reads access token from HttpOnly cookie and
  sets Authorization header for SCAPI proxy requests
- isScapiDomain() utility for identifying Commerce API domains
- Configurable tokenResponseEndpoints and slasEndpointsRequiringAccessToken
  regexes for controlling which endpoints are processed

Client-side (commerce-sdk-react):
- useHttpOnlySessionCookies flag on Auth and CommerceApiProvider
- isAccessTokenExpired() uses access_token_expires_at when HttpOnly enabled
- handleTokenResponse() skips storing tokens in localStorage when HttpOnly
- Provider ensures fetch credentials allow cookies to be sent

Note: TAOB (Trusted Agent on Behalf) and refresh token flows with HttpOnly
cookies will be handled in follow-up work.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@unandyala unandyala requested a review from a team as a code owner February 19, 2026 22:48
@cc-prodsec
Copy link
Collaborator

cc-prodsec commented Feb 19, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@unandyala unandyala closed this Feb 19, 2026
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.

7 participants