Skip to content

Commit

Permalink
fix(backend): secure cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
sukanya-rath authored May 9, 2024
1 parent f59da6a commit c36b5e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const metricsMiddleware = promBundle({
promRegistry: register,
});
const app = express();
app.set('trust proxy', 1);
const apiRouter = express.Router();

const JWTStrategy = passportJWT.Strategy;
Expand All @@ -90,9 +91,13 @@ app.use(
);

const cookie = {
secure: true,
httpOnly: true,
maxAge: 1800000, //30 minutes in ms. this is same as session time. DO NOT MODIFY, IF MODIFIED, MAKE SURE SAME AS SESSION TIME OUT VALUE.
};
if ('local' === config.get('environment')) {
cookie.secure = false;
}

//sets cookies for security purposes (prevent cookie access, allow secure connections only, etc)
const sess = {
Expand All @@ -108,9 +113,6 @@ const sess = {
},
}),
};
if ('production' === config.get('environment')) {
app.set('trust proxy', 1);
}
app.use(session(sess));
//initialize routing and session. Cookies are now only reachable via requests (not js)
app.use(passport.initialize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: BACKEND_URL
value: http://{{ .Release.Name }}-backend
value: "{{ .Release.Name }}-backend.{{.Release.Namespace}}.svc.cluster.local:80"
- name: LOG_LEVEL
value: {{ .Values.env.logLevel }}
- name: SNOWPLOW_URL
Expand Down

0 comments on commit c36b5e8

Please sign in to comment.