Skip to content

Commit

Permalink
refactor: replace csurf with csrf-csrf
Browse files Browse the repository at this point in the history
I've kept the identical same settings as before –
however they are not *ideal* from what I read.
More secure settings will need to be tested a bit more thoroughly first and will be a separate PR.
  • Loading branch information
pano9000 committed Dec 30, 2024
1 parent d570bcd commit cd1a47c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import auth from "../services/auth.js";
import cls from "../services/cls.js";
import sql from "../services/sql.js";
import entityChangesService from "../services/entity_changes.js";
import csurf from "csurf";
import { doubleCsrf } from "csrf-csrf";
import { createPartialContentHandler } from "@triliumnext/express-partial-content";
import rateLimit from "express-rate-limit";
import AbstractBeccaEntity from "../becca/entities/abstract_becca_entity.js";
Expand Down Expand Up @@ -71,10 +71,15 @@ import etapiSpecialNoteRoutes from "../etapi/special_notes.js";
import etapiSpecRoute from "../etapi/spec.js";
import etapiBackupRoute from "../etapi/backup.js";

const csrfMiddleware = csurf({
cookie: {
path: "" // empty, so cookie is valid only for the current path
}
const { doubleCsrfProtection: csrfMiddleware } = doubleCsrf({
getSecret: (req) => req.secret,
cookieOptions: {
path: "", // empty, so cookie is valid only for the current path
secure: false,
sameSite: false,
httpOnly: false,
},
cookieName: "_csrf",
});

const MAX_ALLOWED_FILE_SIZE_MB = 250;
Expand Down

0 comments on commit cd1a47c

Please sign in to comment.