Skip to content

Commit

Permalink
[Unticketed] fix auth bug - allow non ssl cookies in non-prod (#3507)
Browse files Browse the repository at this point in the history
 Only set the "secure" parameter on the session cookie to "true" in prod for now
  • Loading branch information
doug-s-nava authored Jan 13, 2025
1 parent f29151a commit 67d5df0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"node": ">=22.13.0"
},
"scripts": {
"all-checks": "npm run lint && npm run ts:check && npm run test && npm run build",
"all-checks": "npm run lint && npm run ts:check && npm run test && npm run build -- --no-lint",
"build": "next build",
"dev": "NEW_RELIC_ENABLED=false next dev",
"dev:nr": "NODE_OPTIONS='-r @newrelic/next' next dev",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/services/auth/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const createSession = async (token: string) => {
const session = await encrypt(token, expiresAt, clientJwtKey);
cookies().set("session", session, {
httpOnly: true,
secure: true,
secure: environment.ENVIRONMENT === "prod",
expires: expiresAt,
sameSite: "lax",
path: "/",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/services/auth/sessionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const decrypt = async (
});
return payload;
} catch (error) {
console.error("Failed to decrypt session cookie", error);
console.error(`Failed to decrypt session cookie with ${algorithm}`, error);
return null;
}
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/tests/services/auth/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe("createSession", () => {
"encrypted session",
{
httpOnly: true,
secure: true,
secure: false, // true only in prod for now
expires: new Date(0),
sameSite: "lax",
path: "/",
Expand Down

0 comments on commit 67d5df0

Please sign in to comment.