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
+14 -2
View File
@@ -45,7 +45,7 @@ export interface HeaderLookup {
export interface OptRequestContext {
/** Tenant id: from the token when enforced, else from the X-Tenant-Id header. */
tenantId: string;
/** Actor id: from X-Actor-Id header, falling back to the token subject. */
/** Actor id: the verified token subject when enforced; header only in explicit dev mode. */
actorId: string;
/** Correlation/request id (X-Request-Id header, else a fresh uuid). */
requestId: string;
@@ -226,8 +226,20 @@ export async function resolveAuthContext(
ctx,
};
}
// A token proves its own subject, not any actor named in a header.
// Delegation is denied until an explicit, verified grant contract exists.
const headerActor = firstHeader(headers, 'x-actor-id');
if (headerActor && headerActor !== principal.sub) {
return {
ok: false,
status: 403,
code: 'OPT_ACCESS_DENIED',
message: 'X-Actor-Id header disagrees with authenticated token subject',
ctx,
};
}
ctx.tenantId = principal.tenantId;
ctx.actorId = ctx.actorId || principal.sub;
ctx.actorId = principal.sub;
ctx.principal = principal;
return { ok: true, ctx };
}