Replies: 1 comment 3 replies
-
Nice! I see a lot of people not totally understanding how to use I don't think you should need the CSRF token on your separate API. Its purpose is to ensure a secure communication between the app's frontend/backend, not third-party APIs. If you already encrypt the JWT in addition to the signing, it is pretty much all you can do to protect your API, in addition to using short-lived tokens. A JWT is self-contained, meaning once issued, it cannot be revoked (it could be blocklisted if you are made aware that a token has been compromised, but it might not be easy in practice). See also: https://owasp.org/www-community/attacks/csrf |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a separate
express
server setup for websocket connections for my Next.js application. My authorization policy for this web socket is to just use the JWT session token and CSRF token thatnext-auth
provided for the session and are available as a request cookie. I specified my ownencryptionKey
andsigningKey
in thejwt
config object in[...nextAuth].js
so it seems verifying the JWT on the websocket side is as easy as taking these same keys and supplying them to the verify function provided by a library likejsonwebtoken
on myexpress
server.My questions are:
express
server? It's not clear to me what secret information is used for generating/validating the CSRF.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions