feat(payments): bind orders to verified tenant and buyer
CI (SIAX Cloud) / integration (push) Has been skipped
masterplan-lock / check (push) Successful in 4s
CI (SIAX Cloud) / security (push) Successful in 14s
masterplan-lock / check (pull_request) Successful in 4s
CI (SIAX Cloud) / security (pull_request) Successful in 14s
Security Scan (SIAX Cloud) / security (push) Successful in 30s
CI (SIAX Cloud) / quality (push) Successful in 35s
CI (SIAX Cloud) / integration (pull_request) Successful in 25s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 54s
CI (SIAX Cloud) / quality (pull_request) Successful in 1m31s

This commit is contained in:
2026-09-15 19:53:58 +02:00
parent f976f36530
commit a1557b2a7d
19 changed files with 326 additions and 76 deletions
+20
View File
@@ -0,0 +1,20 @@
import { NextResponse, type NextRequest } from "next/server";
import { requireRouteAuth } from "./require-route-auth";
import type { OrderOwner } from "@/lib/orders-store";
export type OrderOwnerAuthResult =
| { response: NextResponse; owner?: never }
| { response?: never; owner: OrderOwner };
/** Payment/order routes require a real verified principal even in dev escape mode. */
export async function requireOrderOwner(req: NextRequest): Promise<OrderOwnerAuthResult> {
const auth = await requireRouteAuth(req);
if (auth.response) return { response: auth.response };
const principal = auth.ctx.principal;
if (!principal?.tenantId || !principal.sub) {
return {
response: NextResponse.json({ error: "OPT_UNAUTHENTICATED", message: "Verified buyer required" }, { status: 401 }),
};
}
return { owner: { tenantId: principal.tenantId, subject: principal.sub } };
}