Fine-Grained Auth
FGA Overview
Hierarchical authorization for .NET apps with query-time filtering.
FGA models resources as a tree. You grant roles on a node. Child nodes inherit access. EF sends filters to SQL Server. You do not load everything and filter in memory.
Define resources (projects, chains, stores), roles (admin, viewer), and permissions (VIEW, EDIT). Grant a role to a user on a resource. Every descendant of that resource inherits the grant.
Organizations, projects, chains, stores, or any hierarchy you define.
Attach reusable permission bundles to a resource and inherit them downward.
Push auth checks into SQL Server instead of loading data and trimming it in memory.
The core feature. Instead of loading all records and filtering in memory, FGA pushes authorization into the SQL query:
var filter = await authService
.GetAuthorizationFilterAsync<Chain>(subjectId, "CHAIN_VIEW");
var chains = await dbContext.Chains
.Where(filter)
.OrderBy(c => c.Name)
.ToListAsync();Users only see rows they may access. Under the hood that becomes a SQL Server TVF call.
Company Admin sees 5 chains:

Store Clerk sees 0 chains (only their store):

builder.AddSqlOS<AppDbContext>();
var app = builder.Build();
app.MapSqlOS();/sqlos/admin/fga/ — browse resources, grants, roles, permissions, and run the access tester.

The value proposition is not just expressive permissions. It is that the same authorization model can drive list filtering, detail checks, dashboard inspection, and SQL-native enforcement from one runtime.
| Concept | Description |
|---|---|
| Resource | A node in the hierarchy (org, project, store) |
| Subject | Who is being authorized (user, agent, service account) |
| Role | A named set of permissions (viewer, editor, admin) |
| Permission | A capability key (CHAIN_VIEW, INVENTORY_EDIT) |
| Grant | Links subject + role + resource; inherits downward |