fix(auth): en (1) tenant per intern serviceprincipal — multi-tenant nekas
CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (push) Successful in 4s
masterplan-lock / check (pull_request) Successful in 8s
CI (SIAX Cloud) / security (pull_request) Successful in 35s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 44s
CI (SIAX Cloud) / integration (pull_request) Successful in 9m48s
CI (SIAX Cloud) / quality (pull_request) Successful in 10m14s

Den delade X-Internal-Token identifierar EN tjänsteprocess, inte flera
oberoende principaler. En allowlist med flera tenants skulle låta varje
tokeninnehavare välja mellan dem — samma klientstyrda auktoritet som guarden
ska ta bort. Multi-tenant-tjänsteåtkomst kräver verifierad
workload-identity-binding (CL0UD-delegation); tills den finns failar en
ambig konfiguration stängt (401) och ingen identitet forwardas.

Tester: multi-tenant nekas utan side effect, en tenant fungerar, 75/75 i
auth+ cross-tenant-sviterna, tsc ren.
This commit is contained in:
SIAX Agent
2026-11-07 16:39:48 +01:00
parent b97ad0b2f4
commit 1a581fde29
3 changed files with 36 additions and 3 deletions
+12 -2
View File
@@ -95,11 +95,21 @@ describe('middleware: internal-token tenant authority comes from server config',
expect(forwarded(res, SERVICE_TENANT_SCOPE_HEADER)).toBe('t_a');
});
it('multiple allowlisted tenants are carried as a scope, not as one verified tenant', async () => {
it('REFUSES an ambiguous multi-tenant allowlist (no workload-identity binding yet)', async () => {
process.env.INTERNAL_SERVICE_TENANTS = 't_a,t_b';
const res = await middleware(req(SCOPED_ROUTE, { 'x-internal-token': INTERNAL_TOKEN }));
expect(res.status).toBe(401);
const body = await res.json();
expect(body.message).toContain('ambiguous');
expect(forwarded(res, 'x-0pt-verified-tenant')).toBeNull();
expect(forwarded(res, SERVICE_TENANT_SCOPE_HEADER)).toBe('t_a,t_b');
expect(forwarded(res, SERVICE_TENANT_SCOPE_HEADER)).toBeNull();
});
it('a single allowlist entry is still forwarded as the service scope', async () => {
process.env.INTERNAL_SERVICE_TENANTS = 't_a';
const res = await middleware(req(SCOPED_ROUTE, { 'x-internal-token': INTERNAL_TOKEN }));
expect(res.status).toBe(200);
expect(forwarded(res, SERVICE_TENANT_SCOPE_HEADER)).toBe('t_a');
});
it('with no configured scope the service principal has no tenant authority (empty scope header)', async () => {