1
0
mirror of synced 2025-12-20 10:28:40 -05:00

Remove CSRF check (#29910)

* Use color_mode for gating "sign up" button

* Remove csrf check

* Add `res.removeHeader('set-cookie')` to cache-control

* Update static-assets.js

* Remove package

* Remove tough-cookie

* Update cache-control.js

* Update cache-control.js

* Update cache-control.js
This commit is contained in:
Kevin Heis
2022-08-15 12:28:42 -07:00
committed by GitHub
parent 242c4c1f72
commit 688a274f1f
24 changed files with 29 additions and 358 deletions

View File

@@ -7,8 +7,6 @@ const cacheControl = cacheControlFactory(60) // 1 minute
function shouldLogException(error) {
const IGNORED_ERRORS = [
// avoid sending CSRF token errors (from bad-actor POST requests)
'EBADCSRFTOKEN',
// Client connected aborted
'ECONNRESET',
]
@@ -41,8 +39,6 @@ export default async function handleError(error, req, res, next) {
// The Cache-Control is short, and let's use the default surrogate
// key just in case it was a mistake.
cacheControl(res)
// Undo the cookie setting that CSRF sets.
res.removeHeader('set-cookie')
// Makes sure the surrogate key is NOT the manual one if it failed.
// This basically unsets what was assumed in the beginning of
// loading all the middlewares.
@@ -76,7 +72,7 @@ export default async function handleError(error, req, res, next) {
}
// If the error contains a status code, just send that back. This is usually
// from a middleware like `express.json()` or `csrf`.
// from a middleware like `express.json()`.
if (error.statusCode || error.status) {
return res.sendStatus(error.statusCode || error.status)
}