Fine-Grained Auth
IHasResourceId
The lower-level resource ID contract used by FGA filters.
IHasResourceId is the lower-level contract used by authorization filters. It exposes the FGA resource ID on a domain entity so query filters can join app rows to accessible resources.
public interface IHasResourceId
{
string ResourceId { get; }
}For protected domain entities whose resource lifecycle should be managed by SqlOS, prefer ISqlOSResourceEntity. It extends IHasResourceId with resource metadata used by SqlOSDbContext<TContext> during SaveChanges / SaveChangesAsync.
public sealed class Workspace : ISqlOSResourceEntity
{
public Guid Id { get; set; }
public string ResourceId { get; set; } = "";
public string Name { get; set; } = "";
public string OrganizationId { get; set; } = "";
public string ResourceTypeId => "workspace";
public string ResourceName => Name;
public string ParentResourceId => $"org::{OrganizationId}";
public string? ResourceDescription => null;
public bool ResourceIsActive => true;
}When you call GetAuthorizationFilterAsync<T>, the filter uses ResourceId to restrict the query to resources the subject can access:
var filter = await authService
.GetAuthorizationFilterAsync<Workspace>(subjectId, "WORKSPACE_VIEW");
var workspaces = await db.Workspaces
.Where(filter)
.OrderBy(x => x.Name)
.ToListAsync(ct);Use plain IHasResourceId directly for lower-level/manual resources where your application owns the FGA resource lifecycle. Use ISqlOSResourceEntity for the normal SDK path.