Class PermissionPolicyServiceCollectionExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Stratara.Identity.AspNetCore.dll
DI extensions that surface the Stratara permission catalog as ASP.NET Core authorization policies, so HTTP endpoints gate on the same permission vocabulary as the mediator and the outbox dispatcher.
public static class PermissionPolicyServiceCollectionExtensions
- Inheritance
-
PermissionPolicyServiceCollectionExtensions
- Inherited Members
Methods
AddStrataraPermissionPolicies(IServiceCollection)
Register the permission policy provider and handler: every permission declared in the
registered PermissionCatalog becomes an on-demand authorization policy —
[Authorize("sims.read")] / .RequireAuthorization("sims.read") — evaluated
through the registered IPermissionResolver. Undeclared policy names defer
to the default provider. Requires a registered catalog and resolver (for example
AddPermissionCatalog(...) + AddCatalogPermissionResolver<TUser>()).
public static IServiceCollection AddStrataraPermissionPolicies(this IServiceCollection services)
Parameters
servicesIServiceCollectionThe service collection to mutate.
Returns
- IServiceCollection
The same service collection, to enable chaining.
Examples
Turns every declared catalog permission into an on-demand authorization policy:
services.AddPermissionCatalog(c => c.Add("sims.read"));
services.AddStrataraPermissionPolicies();
// then: [Authorize("sims.read")]
Remarks
The policy provider is registered via TryAdd — a host that ships its own
IAuthorizationPolicyProvider keeps it and composes the permission lookup
itself.