Datapoint.Mediator.Authorization 4.0.0-beta.7

This is a prerelease version of Datapoint.Mediator.Authorization.
dotnet add package Datapoint.Mediator.Authorization --version 4.0.0-beta.7
                    
NuGet\Install-Package Datapoint.Mediator.Authorization -Version 4.0.0-beta.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Datapoint.Mediator.Authorization" Version="4.0.0-beta.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Datapoint.Mediator.Authorization" Version="4.0.0-beta.7" />
                    
Directory.Packages.props
<PackageReference Include="Datapoint.Mediator.Authorization" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Datapoint.Mediator.Authorization --version 4.0.0-beta.7
                    
#r "nuget: Datapoint.Mediator.Authorization, 4.0.0-beta.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Datapoint.Mediator.Authorization@4.0.0-beta.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Datapoint.Mediator.Authorization&version=4.0.0-beta.7&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Datapoint.Mediator.Authorization&version=4.0.0-beta.7&prerelease
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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