TenantAssignment and readside filtering
All checks were successful
Build and Push / build (push) Successful in 1m23s

This commit is contained in:
2026-04-26 22:58:30 +02:00
parent 7c4e20099d
commit 22fd5fb2cc
14 changed files with 598 additions and 54 deletions

View File

@@ -1,21 +1,14 @@
import { NextResponse } from "next/server";
import { getSessionUser } from "@/lib/session";
import { listTenants } from "@/lib/k8s";
import { listVisibleTenants } from "@/lib/visibility";
export async function GET() {
const user = await getSessionUser();
if (!user)
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
const tenants = await listTenants();
if (user.isPlatform) {
return NextResponse.json(tenants);
}
// Customers see only their own tenant
const own = tenants.filter(
(t) => t.metadata.labels?.["pieced.ch/zitadel-org-id"] === user.orgId
);
return NextResponse.json(own);
const all = await listTenants();
const visible = await listVisibleTenants(user, all);
return NextResponse.json(visible);
}