Notes/src/routes/csrf_protection.ts

16 lines
440 B
TypeScript
Raw Normal View History

2025-01-16 08:25:02 +01:00
import { doubleCsrf } from "csrf-csrf";
import sessionSecret from "../services/session_secret.js";
const doubleCsrfUtilities = doubleCsrf({
getSecret: () => sessionSecret,
cookieOptions: {
path: "", // empty, so cookie is valid only for the current path
secure: false,
sameSite: false,
httpOnly: false
},
cookieName: "_csrf"
});
export const { doubleCsrfProtection } = doubleCsrfUtilities;