Bảo mật cấp hàng bản địa
Mỗi truy vấn cơ sở dữ liệu đều được giới hạn nghiêm ngặt theo ngữ cảnh tenant hiện tại.
Đọc triết lý cơ sở dữ liệu
query.ts
schema.prisma
middleware.ts
1import { withTenant } from '@nebutra/rls'23export const getPosts = withTenant(4 async (ctx) => {5 const data = await prisma.post.findMany({6 where: {7 tenantId: ctx.tenant.id,8 published: true,9 },10 include: { author: true },11 });12 return data;13 }14);
Terminal— rls-audit
$ npx nebutra rls-audit --strict
✔ 0 cross-tenant leaks detected
14 queries scanned in 0.8s