You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// app/utils/csrf.server.tsimport{CSRF}from"remix-utils/csrf/server";import{createCookie}from"react-router";// or cloudflare/denoexportconstcookie=createCookie("csrf",{path: "/",httpOnly: true,secure: process.env.NODE_ENV==="production",sameSite: "lax",secrets: ["s3cr3t"],});exportconstcsrf=newCSRF({
cookie,// what key in FormData objects will be used for the token, defaults to `csrf`formDataKey: "csrf",// an optional secret used to sign the token, recommended for extra safetysecret: "s3cr3t",});
If I supply a secret in new CSRF as shown, I get a Invalid CSRF error from csrf.validate(). I'm not sure if this 'secret' is in place of 'secrets' in createCookie or in addition to it as an extra layer of security.
If it is an extra security how does one go about validating it? Doesn't csrf.validate need to know what the signing key is?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
In the demo from the readme,
If I supply a secret in new CSRF as shown, I get a Invalid CSRF error from csrf.validate(). I'm not sure if this 'secret' is in place of 'secrets' in createCookie or in addition to it as an extra layer of security.
If it is an extra security how does one go about validating it? Doesn't csrf.validate need to know what the signing key is?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions