I have an app with token-based authentication (stateless).
for specific endpoint that serves an pdf file, it was ideal for me to authenticate via cookie.
so I creates a cookie with my access token, with 1 second lifetime , just for the use of this endpoint:
// Set one-time cookie only for this action
Cookie.set("token", token, {
secure: true,
expires: new Date(Date.now() + 1000), // one second lifetime
});
// Open url
const newTab = window.open(
pdfURLForAuthenticatedUsers,
"_blank"
);
Do I need to implement csrf protection in this case? or it is safe enough ?...
thanks!