Datapoint.Mediator.Authorization
4.0.0-beta.7
dotnet add package Datapoint.Mediator.Authorization --version 4.0.0-beta.7
NuGet\Install-Package Datapoint.Mediator.Authorization -Version 4.0.0-beta.7
<PackageReference Include="Datapoint.Mediator.Authorization" Version="4.0.0-beta.7" />
<PackageVersion Include="Datapoint.Mediator.Authorization" Version="4.0.0-beta.7" />
<PackageReference Include="Datapoint.Mediator.Authorization" />
paket add Datapoint.Mediator.Authorization --version 4.0.0-beta.7
#r "nuget: Datapoint.Mediator.Authorization, 4.0.0-beta.7"
#:package Datapoint.Mediator.Authorization@4.0.0-beta.7
#addin nuget:?package=Datapoint.Mediator.Authorization&version=4.0.0-beta.7&prerelease
#tool nuget:?package=Datapoint.Mediator.Authorization&version=4.0.0-beta.7&prerelease
Datapoint.Mediator.Authorization
A Datapoint.Mediator behaviour that authorizes commands, queries and stream queries for the current user, denying access by default. The rules live in your business layer, so they apply the same way from an API, a CLI or an MCP server. Register it with Datapoint.Mediator.Authorization.DependencyInjection.
public sealed class CreateInvoiceAuthorizer : IAuthorizer<CreateInvoice>
{
public ValueTask<AuthorizationDecision> AuthorizeAsync(CreateInvoice action, ClaimsPrincipal principal, CancellationToken cancellationToken = default) =>
new(AuthorizationDecision.AllowIf(principal.IsInRole("Finance")));
}
A decision can carry details of your own, such as the share or rule that applied, for your handlers (IAuthorizationContext) and audit log (IAuthorizationObserver); they never reach the caller. An action with no authorizer is denied, unless it's marked [AllowAnonymousAccess]. To authorize inside the database transaction, register AuthenticationBehavior first and the authorization behaviour after the transaction behaviour, with RequireTransaction. With no signed-in user, AuthenticationRequiredException is thrown.
Security: messages aren't authorized. Never publish a message built from user input: send an authorized command, and publish the message from its handler.
Documentation: Authorization · Security checklist
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Datapoint.Mediator.Abstractions (>= 4.0.0-beta.7)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Datapoint.Mediator.Authorization:
| Package | Downloads |
|---|---|
|
Datapoint.Mediator.Authorization.AspNetCore
Provides the ASP.NET Core request's user to the Datapoint.Mediator authorization behaviour, for APIs and MCP servers over HTTP. |
|
|
Datapoint.Mediator.Authorization.DependencyInjection
Registers the Datapoint.Mediator authorization behaviour and authorizers with Microsoft.Extensions.DependencyInjection. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.0-beta.7 | 40 | 11/4/2026 |
| 4.0.0-beta.6 | 137 | 11/3/2026 |
| 4.0.0-beta.5 | 49 | 11/3/2026 |
| 4.0.0-beta.4 | 43 | 11/3/2026 |
| 4.0.0-beta.3 | 145 | 11/2/2026 |
| 4.0.0-beta.2 | 74 | 11/1/2026 |
| 4.0.0-beta.1 | 59 | 11/1/2026 |