feat: add guarded document workbench foundations
CI (SIAX Cloud) / integration (push) Skipped
CI (SIAX Cloud) / sonar (push) Skipped
masterplan-lock / check (push) Successful in 5s
Security Scan (SIAX Cloud) / security (push) Successful in 15s
CI (SIAX Cloud) / security (push) Successful in 16s
CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (pull_request) Successful in 7s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 21s
CI (SIAX Cloud) / security (pull_request) Successful in 25s
CI (SIAX Cloud) / quality (push) Successful in 1m17s
CI (SIAX Cloud) / integration (pull_request) Successful in 54s
CI (SIAX Cloud) / quality (pull_request) Successful in 1m7s

This commit is contained in:
2026-11-02 01:26:36 +01:00
parent cb01f948eb
commit bd1c20edb2
34 changed files with 1992 additions and 19 deletions
+19
View File
@@ -66,3 +66,22 @@ export function assertTenantMatchesVerified(
}
return null;
}
/** Bind document operations to middleware's verified subject; never accept a conflicting body actor. */
export function resolveDocumentActor(
request: NextRequest,
requestedActor: string | undefined,
): { actorId?: string; response?: NextResponse } {
const verified = request.headers.get('x-0pt-verified-sub');
if (verified && requestedActor && requestedActor !== verified) {
return {
response: NextResponse.json(
{ error: 'OPT_ACCESS_DENIED', message: 'actor_id disagrees with the authenticated token subject' },
{ status: 403 },
),
};
}
// Absence is the existing unauthenticated development path. In enforced
// mode middleware always installs the verified subject before this route.
return { actorId: verified || requestedActor };
}