Build and extend
Add and enforce a permission
Register an action, apply it to the API and verify both role and organizational access.
Define the action and its owner
Start from one user capability, such as viewing an asset or approving a request. Name its resource and action consistently. The registry builds names as Permissions.<Resource>.<Action>, while the description is a display label.
Catalog demonstrates this with Catalog.Brands plus Create. Store constants in the owning module's Contracts project so the runtime and permitted consumers agree on the same identifier. Changing a permission name is a behavior change for stored role claims, not a cosmetic label edit.
Add a definition and register the catalog
The existing Catalog pattern is:
public const string Resource = "Catalog.Brands";
public const string Create = $"Permissions.{Resource}.Create";
Its All collection contains a matching definition:
new FshPermission("Create Brands", ActionConstants.Create, Brands.Resource)
The module's ConfigureServices calls PermissionConstants.Register(CatalogPermissions.All). Follow this three-part relationship for your own resource: constant, definition and registration. A constant with no catalog entry can protect an endpoint with an action that administrators cannot assign through the expected catalog.
IsBasic includes the permission in the built-in Basic role's target catalog. IsRoot classifies a platform-level permission. Choose these flags according to the actual privilege needed; do not make a mutation basic simply to make a demo pass. Custom roles require their own intentional assignment.
Enforce the API boundary
Add .RequirePermission(YourPermissions.Action) to the endpoint within the existing authorization setup. Group requirements and endpoint requirements are cumulative. If a group requires A and its endpoint requires B, test a user with both and users missing each one separately.
Do not use a blank permission string and do not add AllowAnonymous to work around a 403. Diagnose the authenticated tenant, catalog registration and role assignment. The authorization implementation denies empty requirement sets.
For a scoped resource, checking the endpoint permission is only the first boundary. Verify the resource's organizational unit in the handler or access service using the matching permission before reading or mutating it.
Opt into organizational scope when needed
Implement IOrganizationScopePermissions to expose your module's supported scope-permission names and register that provider in DI. Workflows uses WorkflowScopePermissions; Tickets has its own provider.
Use IOrganizationAccess for the unit-specific decision. The provider marks an action as scope-capable; it does not create grants for users. A user still needs the action permission and a live unit grant, with descendant coverage only where explicitly configured. See authorization for the exact distinction.
Update the experience and prove the rule
Connect the frontend route or button guard to the same action, add English and Arabic labels in the client's localization system, and ensure a direct API call is still rejected without permission. A hidden button alone is not an access-control test.
Test a custom role with the new grant, the same role without it, an already signed-in session after grant removal, another tenant, and an expired scope grant where applicable. Confirm the permission appears in the catalog and that built-in role synchronization behaves as intended. Review cache invalidation if a changed grant seems stale.
Run architecture checks and the relevant integration tests. Use Catalog's permission-registration tests as a reference, then add cases for your business endpoint rather than only asserting that a constant exists.