qbo_auth: заголовки no-store/Referrer-Policy; требования Intuit: раздел E (безопасность), M7 по решению Юрия
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,13 @@ export function buildApi(auth: QboAuth, token: string, sync?: QboSync, webhook?:
|
||||
done(e as Error, undefined);
|
||||
}
|
||||
});
|
||||
// требования Intuit: ответы с токенами и страницы действий не кэшируются, адрес с code/state не уходит в Referer
|
||||
app.addHook("onSend", async (_req, reply) => {
|
||||
reply.header("Cache-Control", "no-store");
|
||||
reply.header("Pragma", "no-cache");
|
||||
reply.header("Referrer-Policy", "no-referrer");
|
||||
reply.header("X-Content-Type-Options", "nosniff");
|
||||
});
|
||||
app.addHook("onRequest", async (req, reply) => {
|
||||
const path = req.url.split("?")[0];
|
||||
if (path === "/healthz" || path === "/callback" || path === "/webhook" || path === "/tests") return;
|
||||
|
||||
@@ -33,7 +33,10 @@ describe("вебхук Intuit", () => {
|
||||
|
||||
it("страница /tests открыта, действия /tests/* закрыты токеном, заметка принимается", async () => {
|
||||
const app = buildApi({} as QboAuth, "svc");
|
||||
expect((await app.inject({ url: "/tests" })).statusCode).toBe(200);
|
||||
const page = await app.inject({ url: "/tests" });
|
||||
expect(page.statusCode).toBe(200);
|
||||
expect(page.headers["cache-control"]).toBe("no-store");
|
||||
expect(page.headers["referrer-policy"]).toBe("no-referrer");
|
||||
expect((await app.inject({ url: "/tests/status" })).statusCode).toBe(401);
|
||||
expect((await app.inject({ method: "POST", url: "/tests/disconnect" })).statusCode).toBe(401);
|
||||
const h = { authorization: "Bearer svc", "content-type": "application/json" };
|
||||
|
||||
Reference in New Issue
Block a user