-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
enhancementNew feature or requestNew feature or requestfeatureThis label is in use for minor version incrementsThis label is in use for minor version increments
Milestone
Description
Title: Add authorization pipeline behaviors for command/query access control
Labels: enhancement, mediator, new-package
Body:
Problem
CQRS architectures commonly need authorization checks before handler execution. Currently, consumers must implement this themselves as a custom pipeline behavior or embed authorization logic in each handler.
Proposed Solution
Create a Cortex.Mediator.Behaviors.Authorization package:
IAuthorizationRequirement<TRequest>interface that handlers implement to define requirementsAuthorizationCommandBehavior<TCommand, TResult>-- resolves and checks allIAuthorizationRequirement<TCommand>before executionAuthorizationQueryBehavior<TQuery, TResult>-- same for queries- Integration with
Microsoft.AspNetCore.Authorization.IAuthorizationServicefor policy-based auth UnauthorizedExceptionthrown when authorization fails
public class CreateOrderAuthorizationRequirement : IAuthorizationRequirement<CreateOrderCommand>
{
public Task<AuthorizationResult> CheckAsync(
CreateOrderCommand command,
IServiceProvider services,
CancellationToken cancellationToken)
{
// Check if current user can create orders
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestfeatureThis label is in use for minor version incrementsThis label is in use for minor version increments