Skip to content

Commit

Permalink
fix cookie on dev domain
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgros committed Nov 11, 2024
1 parent 08c953c commit acdff2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import SparkMD5 from 'spark-md5'
import UniversalCookies from 'universal-cookie'
import {
ACCESS_TOKEN_COOKIE_KEY,
getCookieDomain,
OAuth2State,
SynapseConstants,
} from '../utils'
Expand Down Expand Up @@ -1974,6 +1975,7 @@ export const setAccessTokenCookie = async (
// expires in 10 days (see SWC-6190)
maxAge: 60 * 60 * 24 * 10,
path: '/',
domain: getCookieDomain(),
})
}
} else {
Expand Down
10 changes: 7 additions & 3 deletions packages/synapse-react-client/src/utils/AppUtils/AppUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ export const ONE_SAGE_REDIRECT_COOKIE_KEY =
'org.sagebionetworks.cookies.redirect-after-login'

export const getCookieDomain = () => {
return window.location.hostname.toLowerCase().endsWith('.synapse.org')
? '.synapse.org'
: undefined
if (window.location.hostname.toLowerCase().endsWith('.synapse.org')) {
return '.synapse.org'
}
if (window.location.hostname.toLowerCase().endsWith('dev.sagebase.org')) {

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

'
dev.sagebase.org
' may be preceded by an arbitrary host name.
return '.dev.sagebase.org'
}
return undefined
}

export function storeRedirectURLForOneSageLoginAndGotoURL(href: string) {
Expand Down

0 comments on commit acdff2f

Please sign in to comment.