Class AuthorizingCommandOutboxDispatcherServiceCollectionExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Stratara.Infrastructure.dll
Service-collection extensions that wrap the registered ICommandOutboxDispatcher with Stratara.Infrastructure.Authorization.AuthorizingCommandOutboxDispatcher, enforcing RequireRoleAttribute and RequirePermissionAttribute checks on every enqueued command (permission enforcement activates when an IPermissionResolver is registered).
public static class AuthorizingCommandOutboxDispatcherServiceCollectionExtensions
- Inheritance
-
AuthorizingCommandOutboxDispatcherServiceCollectionExtensions
- Inherited Members
Methods
AddAuthorizingCommandOutboxDispatcher(IServiceCollection)
Registers Stratara.Infrastructure.Authorization.AuthorizingCommandOutboxDispatcher as the ICommandOutboxDispatcher (scoped), decorating whichever dispatcher was registered last — or Stratara.Outbox.RabbitMQ.Outbox.CommandOutboxDispatcher when none was — and keeping Stratara.Outbox.RabbitMQ.Outbox.CommandOutboxDispatcher available for direct resolution.
public static IServiceCollection AddAuthorizingCommandOutboxDispatcher(this IServiceCollection services)
Parameters
servicesIServiceCollectionThe service collection.
Returns
- IServiceCollection
The same service collection for chaining.
Examples
Register it after the dispatcher it decorates, so the outbox path enforces the same guards the mediator does:
services.AddOutboxDispatcher();
services.AddAuthorizingCommandOutboxDispatcher();
Remarks
The decorated dispatcher moves to a keyed registration under the key
typeof(ICommandOutboxDispatcher). A dispatcher registration made after this call that replaces
that keyed slot, as the Orleans execution model's does, stays authorized, so the two compose in
either order. Calling this twice decorates once.