Skip to content

Commit b2e1a3e

Browse files
authored
Merge pull request #961 from pano9000/fix-csrf-settings
fix(csrf): set more secure csrf related settings
2 parents 283a12b + 5f605b3 commit b2e1a3e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/routes/csrf_protection.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const doubleCsrfUtilities = doubleCsrf({
66
cookieOptions: {
77
path: "", // empty, so cookie is valid only for the current path
88
secure: false,
9-
sameSite: false,
10-
httpOnly: false
9+
sameSite: "strict",
10+
httpOnly: true
1111
},
1212
cookieName: "_csrf"
1313
});

src/routes/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function index(req: Request, res: Response) {
2424
//'overwrite' set to false (default) => the existing token will be re-used and validated
2525
//'validateOnReuse' set to false => if validation fails, generate a new token instead of throwing an error
2626
const csrfToken = generateCsrfToken(req, res, false, false);
27-
log.info(`Generated CSRF token ${csrfToken} with secret ${res.getHeader("set-cookie")}`);
27+
log.info(`CSRF token generation: ${csrfToken ? "Successful" : "Failed"}`);
2828

2929
// We force the page to not be cached since on mobile the CSRF token can be
3030
// broken when closing the browser and coming back in to the page.

0 commit comments

Comments
 (0)