-
Notifications
You must be signed in to change notification settings - Fork 212
@ W-21066921 @W-21201637: Add HttpOnly session cookies for SLAS private client proxy #3680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
unandyala
merged 15 commits into
feature/httponly-session-cookies
from
unandyala.httponly-cookies-private-client
Feb 23, 2026
Merged
Changes from 5 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c44ddf1
Add HttpOnly session cookies for SLAS private client proxy
unandyala 0f689e1
add changelog
unandyala cbdfe90
fix lint errors
unandyala fd41b17
fix lint errors
unandyala b71897f
fix changelog
unandyala 1184547
fix changelog
unandyala 88427d9
fix changelog
unandyala 7ab5c31
fix doc
unandyala 2980ddf
fix doc
unandyala 1e9bafe
small refactor
unandyala 9d46554
small refactor
unandyala a22fa1c
refactor
unandyala a088f32
fix lint errors
unandyala dbd0918
minor fix
unandyala 6090605
minor fix
unandyala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,8 @@ export interface CommerceApiProviderProps extends ApiClientConfigParams { | |
| apiClients?: ApiClients | ||
| disableAuthInit?: boolean | ||
| hybridAuthEnabled?: boolean | ||
| /** When true, proxy returns tokens in HttpOnly cookies. */ | ||
| useHttpOnlySessionCookies?: boolean | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -145,12 +147,21 @@ const CommerceApiProvider = (props: CommerceApiProviderProps): ReactElement => { | |
| refreshTokenGuestCookieTTL, | ||
| apiClients, | ||
| disableAuthInit = false, | ||
| hybridAuthEnabled = false | ||
| hybridAuthEnabled = false, | ||
| useHttpOnlySessionCookies = false | ||
| } = props | ||
|
|
||
| // Set the logger based on provided configuration, or default to the console object if no logger is provided | ||
| const configLogger = logger || console | ||
|
|
||
| // When HttpOnly cookies are enabled, ensure fetch credentials allow cookies to be sent. | ||
| // Override 'omit' or unset to 'same-origin'; keep 'same-origin' or 'include' as-is. | ||
| const effectiveFetchOptions = | ||
|
||
| useHttpOnlySessionCookies && | ||
| (!fetchOptions?.credentials || fetchOptions.credentials === 'omit') | ||
| ? {...fetchOptions, credentials: 'same-origin' as RequestCredentials} | ||
| : fetchOptions | ||
|
|
||
| const auth = useMemo(() => { | ||
| return new Auth({ | ||
| clientId, | ||
|
|
@@ -160,7 +171,7 @@ const CommerceApiProvider = (props: CommerceApiProviderProps): ReactElement => { | |
| proxy, | ||
| redirectURI, | ||
| headers, | ||
| fetchOptions, | ||
| fetchOptions: effectiveFetchOptions, | ||
| fetchedToken, | ||
| enablePWAKitPrivateClient, | ||
| privateClientProxyEndpoint, | ||
|
|
@@ -171,7 +182,8 @@ const CommerceApiProvider = (props: CommerceApiProviderProps): ReactElement => { | |
| passwordlessLoginCallbackURI, | ||
| refreshTokenRegisteredCookieTTL, | ||
| refreshTokenGuestCookieTTL, | ||
| hybridAuthEnabled | ||
| hybridAuthEnabled, | ||
| useHttpOnlySessionCookies | ||
| }) | ||
| }, [ | ||
| clientId, | ||
|
|
@@ -181,7 +193,7 @@ const CommerceApiProvider = (props: CommerceApiProviderProps): ReactElement => { | |
| proxy, | ||
| redirectURI, | ||
| headers, | ||
| fetchOptions, | ||
| effectiveFetchOptions, | ||
| fetchedToken, | ||
| enablePWAKitPrivateClient, | ||
| privateClientProxyEndpoint, | ||
|
|
@@ -193,7 +205,8 @@ const CommerceApiProvider = (props: CommerceApiProviderProps): ReactElement => { | |
| refreshTokenRegisteredCookieTTL, | ||
| refreshTokenGuestCookieTTL, | ||
| apiClients, | ||
| hybridAuthEnabled | ||
| hybridAuthEnabled, | ||
| useHttpOnlySessionCookies | ||
| ]) | ||
|
|
||
| const dwsid = auth.get(DWSID_COOKIE_NAME) | ||
|
|
@@ -212,7 +225,7 @@ const CommerceApiProvider = (props: CommerceApiProviderProps): ReactElement => { | |
| throwOnBadResponse: true, | ||
| fetchOptions: { | ||
| ...options.fetchOptions, | ||
| ...fetchOptions | ||
| ...effectiveFetchOptions | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -252,7 +265,7 @@ const CommerceApiProvider = (props: CommerceApiProviderProps): ReactElement => { | |
| currency | ||
| }, | ||
| throwOnBadResponse: true, | ||
| fetchOptions | ||
| fetchOptions: effectiveFetchOptions | ||
| } | ||
|
|
||
| return { | ||
|
|
@@ -279,7 +292,7 @@ const CommerceApiProvider = (props: CommerceApiProviderProps): ReactElement => { | |
| shortCode, | ||
| siteId, | ||
| proxy, | ||
| fetchOptions, | ||
| effectiveFetchOptions, | ||
| locale, | ||
| currency, | ||
| headers?.['correlation-id'], | ||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of bufferSeconds is to avoid race conditions where a token is technically still valid when the check happens, but expires by the time the SCAPI request reaches the server. By refreshing 60 seconds early, you ensure the token is still valid when the downstream API processes the request.
The original code has the same pattern