Revalidate consent sessions after request body upload

This commit is contained in:
Thomas Durieux committed 2026-10-08 16:24:40 +00:00
1 parent 7b60979c96
commit c24f6d4e94
2 files changed
+69

No files matched your search

+19
View File
@@ -186,6 +186,25 @@ export function createReviewConsentRouter(
}
});
router.use(express.json({ limit: 12288, strict: true, inflate: false }));
// Uploads can outlive the session checked before body parsing. Revalidate
// before any provider call or consent write, not only before the response.
router.use(async (req, res, next) => {
try {
const actor = res.locals.consentActor as Context;
const fresh = await current(req);
if (res.destroyed || res.headersSent || res.locals.consentSignal.aborted)
return;
if (
!fresh ||
fresh.accountId !== actor.accountId ||
fresh.sessionId !== actor.sessionId
)
return reject(res, 401, "unauthorized");
next();
} catch {
reject(res, 503, "unavailable");
}
});
router.post(["/preview", "/confirm"], async (req, res) => {
const actor = res.locals.consentActor as Context;
try {