PouryaKit.Security 0.1.0-preview.2

This is a prerelease version of PouryaKit.Security.
dotnet add package PouryaKit.Security --version 0.1.0-preview.2
                    
NuGet\Install-Package PouryaKit.Security -Version 0.1.0-preview.2
                    
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="PouryaKit.Security" Version="0.1.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PouryaKit.Security" Version="0.1.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="PouryaKit.Security" />
                    
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 PouryaKit.Security --version 0.1.0-preview.2
                    
#r "nuget: PouryaKit.Security, 0.1.0-preview.2"
                    
#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 PouryaKit.Security@0.1.0-preview.2
                    
#: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=PouryaKit.Security&version=0.1.0-preview.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PouryaKit.Security&version=0.1.0-preview.2&prerelease
                    
Install as a Cake Tool

PouryaKit.Security

NuGet .NET 10 License: MIT

PouryaKit.Security

Permissions on commands and queries, and PBKDF2 password hashing. You put [RequiresPermission] on a command or query, and the pipeline's authorization step asks your application's IActorPermissions before validation and the handler run. An Actor without the permission gets an Error and nothing commits. The Kit issues no token and has no role system, policy framework or identity store.

Install

dotnet add package PouryaKit.Security --prerelease

When to use it

  • A command or query may run only for Actors that hold a permission.
  • You supply the permissions an Actor holds, from claims or your own store.
  • You decide what a continuation or a system Actor may run.
  • Your application stores its own passwords and needs to hash, verify and upgrade them.

It plugs into the pipeline of PouryaKit.Cqrs. PouryaKit.Security.JwtBearer turns bearer tokens into the Actor and, where the token carries one, the tenant.

Quick start

Declare the permission on the record, as the Proving Sample does:

[RequiresPermission(RemoveProductsCommand.Permission)]
internal sealed record RemoveProductsCommand(IReadOnlyList<string> Names)
    : Command<int>,
        IInvalidatesCache
{
    public const string Permission = "catalog.products.remove";

    public IReadOnlyCollection<string> InvalidatedCacheTags => [GetProductQuery.ProductsTag];
}

Register the check in the Composition Root and your source of permissions in the Host:

module.AddPouryaKitPermissions();
builder.Services.AddScoped<IActorPermissions, CallerPermissions>();

Say which permissions an Actor holds:

public sealed class CallerPermissions(IHttpContextAccessor http, IOptions<PouryaKitWebOptions> web)
    : IActorPermissions
{
    public const string ClaimType = "permission";

    public Task<bool> HasPermissionAsync(
        OperationContext context,
        string permission,
        CancellationToken cancellationToken
    )
    {
        ArgumentNullException.ThrowIfNull(context);
        var caller = http.HttpContext?.User;
        return Task.FromResult(
            caller?.Identity?.IsAuthenticated == true
                && context.Actor.Kind == ActorKind.Person
                && caller.FindFirstValue(web.Value.ActorClaim) == context.Actor.Id
                && caller.HasClaim(ClaimType, permission)
        );
    }
}

What you get

  • One declared rule, checked in one place in the pipeline, before validation and the handler.
  • A denial that is an Error, with nothing committed.
  • A trusted continuation that is not asked again, such as a delivery the Kit restored.
  • Password hashes that say how they were made, so a hasher can upgrade them.

Nothing holds a permission by default. The Kit reads no claim itself: your IActorPermissions decides for every Actor, a named system Actor included. Match the claims to the context's Actor, since code inside a request may run an Operation as someone else.

Learn more

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 PouryaKit.Security:

Package Downloads
PouryaKit.Reporting.Module

The Kit's report Module: report jobs generated in the background, stored through the Host's file storage and served to their requester by a time-limited link.

PouryaKit.Security.JwtBearer

JWT bearer authentication for a Host, whose verified claims name the Actor and the tenant of each Operation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-preview.2 78 11/1/2026
0.1.0-preview.1 79 10/31/2026
0.1.0-preview.0.28 78 10/26/2026