Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Nov 17, 2024
2 parents d34f014 + 3ed44ec commit dccf2bd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions __fixtures__/test-project/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"autoprefixer": "^10.4.20",
"postcss": "^8.4.47",
"postcss": "^8.4.49",
"postcss-loader": "^8.1.1",
"prettier-plugin-tailwindcss": "^0.5.12",
"tailwindcss": "^3.4.14"
"tailwindcss": "^3.4.15"
}
}
51 changes: 26 additions & 25 deletions packages/auth-providers/dbAuth/api/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,34 @@ const getPort = () => {
// When in development environment, check for auth impersonation cookie
// if user has generated graphiql headers
const eventGraphiQLHeadersCookie = (event: APIGatewayProxyEvent | Request) => {
if (process.env.NODE_ENV === 'development') {
const impersationationHeader = getEventHeader(
event,
'rw-studio-impersonation-cookie',
)

if (impersationationHeader) {
return impersationationHeader
}
if (process.env.NODE_ENV !== 'development') {
return
}

// TODO: Remove code below when we remove the old way of passing the cookie
// from Studio, and decide it's OK to break compatibility with older Studio
// versions
try {
if (!isFetchApiRequest(event)) {
const jsonBody = JSON.parse(event.body ?? '{}')
return (
jsonBody?.extensions?.headers?.cookie ||
jsonBody?.extensions?.headers?.Cookie
)
}
} catch {
// sometimes the event body isn't json
return
}
const impersationationHeader = getEventHeader(
event,
'rw-studio-impersonation-cookie',
)

if (impersationationHeader) {
return impersationationHeader
}

return
// TODO: Remove code below when we remove the old way of passing the cookie
// from Studio, and decide it's OK to break compatibility with older Studio
// versions
try {
if (!isFetchApiRequest(event)) {
const jsonBody = JSON.parse(event.body ?? '{}')
return (
jsonBody?.extensions?.headers?.cookie ||
jsonBody?.extensions?.headers?.Cookie
)
}
} catch {
// sometimes the event body isn't json
return
}
}

// decrypts session text using old CryptoJS algorithm (using node:crypto library)
Expand Down Expand Up @@ -97,6 +97,7 @@ const legacyDecryptSession = (encryptedText: string) => {
export const extractCookie = (event: APIGatewayProxyEvent | Request) => {
return eventGraphiQLHeadersCookie(event) || getEventHeader(event, 'Cookie')
}

// whether this encrypted session was made with the old CryptoJS algorithm
export const isLegacySession = (text: string | undefined) => {
if (!text) {
Expand Down

0 comments on commit dccf2bd

Please sign in to comment.