Fine-Grained Auth
Capability Checks
Root-level permission checks for global gates.
HasCapabilityAsync checks whether a subject has a specific permission anywhere in the resource tree. Use it for broad capability gates where you don't have a specific resource ID.
var canCreateChains = await authService.HasCapabilityAsync(subjectId, "CHAIN_EDIT");
if (!canCreateChains)
return Results.Json(new { error = "Permission denied" }, statusCode: 403);| Scenario | Method |
|---|---|
| "Can this user edit this chain?" | CheckAccessAsync with a resource ID |
| "Can this user edit any chain?" | HasCapabilityAsync |
| "Show me all chains this user can see" | GetAuthorizationFilterAsync |
HasCapabilityAsync is useful for: