Pragmatic.Identity.Local 1.0.0-alpha.5

This is a prerelease version of Pragmatic.Identity.Local.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Pragmatic.Identity.Local --version 1.0.0-alpha.5
                    
NuGet\Install-Package Pragmatic.Identity.Local -Version 1.0.0-alpha.5
                    
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="Pragmatic.Identity.Local" Version="1.0.0-alpha.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pragmatic.Identity.Local" Version="1.0.0-alpha.5" />
                    
Directory.Packages.props
<PackageReference Include="Pragmatic.Identity.Local" />
                    
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 Pragmatic.Identity.Local --version 1.0.0-alpha.5
                    
#r "nuget: Pragmatic.Identity.Local, 1.0.0-alpha.5"
                    
#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 Pragmatic.Identity.Local@1.0.0-alpha.5
                    
#: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=Pragmatic.Identity.Local&version=1.0.0-alpha.5&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Pragmatic.Identity.Local&version=1.0.0-alpha.5&prerelease
                    
Install as a Cake Tool

Pragmatic.Identity

Identity and authentication for the Pragmatic.Design ecosystem: a structured ICurrentUser that works in HTTP requests, background jobs, and tests, layering up to database-backed identity with temporal roles and groups.

The Problem

ASP.NET Core's ClaimsPrincipal is a transport object, not a domain abstraction. Every service that needs the current user repeats the same pattern: resolve IHttpContextAccessor, null-check HttpContext, navigate claims with magic-string URIs, and special-case each provider. Background jobs have no HttpContext at all, so the whole pattern fails outside HTTP.

// Without Pragmatic.Identity: magic strings, fragile, HTTP-only
var userId = principal?.FindFirst("sub")?.Value
    ?? principal?.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier")?.Value;

The Solution

Replace ClaimsPrincipal with a structured ICurrentUser (identity + authorization + authentication sub-objects). Claim mapping is centralized and configurable; the same code runs across HTTP (ClaimsPrincipalUserAccessor), background jobs (SystemUser), and tests, unchanged. Dev vs production auth switches by configuration (HTTP headers in dev, JWT in production).

public class OrderService(ICurrentUser currentUser)
{
    public VoidResult<ForbiddenError> CreateOrder(CreateOrderRequest request)
    {
        var userId   = currentUser.Id;
        var tenantId = currentUser.TenantId;
        if (!currentUser.Authorization.HasPermission("orders.create"))
            return ForbiddenError.MissingPermission("orders.create");
        // ...
        return VoidResult<ForbiddenError>.Success();
    }
}

Packages

Package Role
Pragmatic.Identity SystemUser, identity options, claim mapping; no ASP.NET Core dependency
Pragmatic.Identity.AspNetCore ClaimsPrincipal → ICurrentUser, header-based development identity
Pragmatic.Identity.Local Self-contained local identity: signup, login, password reset (LocalIdentityPackage)
Pragmatic.Identity.Local.Jwt JWT issuing and bearer authentication: UseJwtAuthentication()
Pragmatic.Identity.Oidc Bearer tokens from any external OpenID Connect provider: UseOidcAuthentication()
Pragmatic.Identity.Keycloak Keycloak realm roles, plus an admin client for provisioning: UseKeycloakAuthentication()
Pragmatic.Identity.Persistence EF Core stores for roles, groups and permissions, with temporal assignments
Pragmatic.Identity.Auditing Failed logins and lockouts on the Audit trail, pseudonymised: AddIdentitySecurityAuditing()

ICurrentUser itself lives in Pragmatic.Abstractions, so a library can consume it without any of these.

Installation

dotnet add package Pragmatic.Identity
dotnet add package Pragmatic.Identity.Local.Jwt   # optional: JWT authentication

Quick Start

// JWT from the Jwt section of the configuration: Key, Issuer, Audience
app.UseJwtAuthentication();

// consume the current user anywhere: no IHttpContextAccessor, no magic strings
public class Handler(ICurrentUser user) { /* user.Id, user.TenantId, user.Authorization.HasPermission(...) */ }

Full walkthrough: Getting Started.

What you get

  • ICurrentUser: identity, authorization, authentication sub-objects; multi-value claims, tenant, impersonation; works in HTTP, jobs, and tests.
  • Local identity: signup/login/password-reset actions (Pragmatic.Identity.Local).
  • JWT: bearer authentication with configurable issuer/audience/expiry.
  • Users: a plain entity marked [PragmaticUser]; the generator owns its identity members and EF configuration.
  • Persistence: EF stores for roles, groups and permissions, with temporal assignments. There is no JIT provisioning: creating a local record on first external login is not implemented (see Persistence).
  • Authorization integration: feeds Authorization's permission resolution.

Status

Functional within 1.0.0-alpha: ICurrentUser, local identity, JWT, and EF-backed persistence. See the roadmap.

Documentation

Guide What you'll learn
Concepts ICurrentUser model, claim mapping, accessors, the permission chain
Getting Started Wire authentication, consume the current user
Packages The core packages and how they layer
JWT Authentication Bearer tokens, issuer/audience/expiry, signing keys
Dev Authentication Header-based auth for development and tests
Persistence EF stores, temporal roles, external identities, [PragmaticUser]
Common Mistakes The most frequent identity pitfalls
Troubleshooting Problem/solution guide

Requirements

  • .NET 10.0+

License

Part of the Pragmatic.Design ecosystem. See Licensing. Pragmatic.Identity is licensed under the PolyForm Small Business 1.0.0 license (free for small businesses; commercial license above the threshold).

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 Pragmatic.Identity.Local:

Package Downloads
Pragmatic.Identity.Local.Jwt

JWT authentication handler for Pragmatic.Identity.Local. Generates and validates JWT tokens from local credentials (login/register).

Pragmatic.Identity.Auditing

Records Pragmatic.Identity security events on the Pragmatic.Audit trail, pseudonymised: a failed login against a known account carries its reference, one against an unknown identity carries none.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.6 106 11/21/2026
1.0.0-alpha.5 65 11/21/2026
1.0.0-alpha.4 122 11/16/2026
1.0.0-alpha.3 396 10/17/2026
1.0.0-alpha.2 133 10/12/2026
1.0.0-alpha.1 359 10/3/2026