AndreGoepel.Marten.Identity 1.1.0

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

AndreGoepel.Marten.Identity

ASP.NET Core Identity stores backed by Marten (PostgreSQL). Provides event-sourced user and role stores, cookie login middleware, and DI extensions ready to drop into any ASP.NET Core application.

Requirements

  • .NET 10
  • Marten 8.x (Marten.AspNetCore)
  • PostgreSQL

Installation

dotnet add package AndreGoepel.Marten.Identity

Usage

1. Configure Marten and wire up Identity stores

builder.Services.AddMartenIdentity();

builder.Services.AddMarten(options =>
{
    options.Connection(connectionString);
    options.InitializeIdentity();   // registers user, role, and user-role projections
    options.AutoCreateSchemaObjects = AutoCreate.All;
})
.IntegrateWithWolverine(); // optional — only needed when using Wolverine

AddMartenIdentity accepts an optional Action<IdentityOptions> to customise password rules, lockout policy, etc.

2. Add middleware

Call UseMartenIdentityMiddleware() after UseAuthentication() / UseAuthorization():

app.UseAuthentication();
app.UseAuthorization();
app.UseMartenIdentityMiddleware();

This registers two middleware components:

Middleware Purpose
SetupRedirectMiddleware Redirects to /Setup until an administrator exists, then blocks /Setup
CookieLoginMiddleware Exchanges a one-time login key for an authentication cookie (used by the setup flow)

First-run setup security

Before the first administrator exists, /Setup is reachable without authentication — that is unavoidable, since no operator credentials exist yet. Whoever completes setup first becomes the un-deletable root administrator, so a freshly deployed instance is exposed until setup is finished. To close the "race to setup" window:

  • Do not expose a new instance to untrusted networks before completing setup. Provision behind a firewall / private network, finish setup, then open it up.
  • Treat SetupRedirectMiddleware as the authoritative gate. Once an administrator holds the Administrator role, the middleware redirects /Setup away unconditionally, so it cannot be re-run to mint a second root admin. Setup completion now requires a user that actually holds the role — not merely that the role and some user both exist.
  • For internet-facing deployments, gate your host's /Setup page with an out-of-band bootstrap secret (e.g. an environment variable the operator must supply) so an attacker cannot claim the first admin even if they reach the instance first.
  • The /Setup redirect uses request headers to detect page navigations; that heuristic is a UX convenience, not a security boundary. Keep [Authorize] on every administrative page — never rely on the redirect to protect them.

What's included

Namespace Contents
AndreGoepel.Marten.Identity.Users User, UserId, UserStore, event-sourced UserProjection, passkey support
AndreGoepel.Marten.Identity.Roles Role, RoleId, RoleStore, event-sourced RoleProjection, built-in Roles constants
AndreGoepel.Marten.Identity.UserRoles UserRoleAssignment projection for efficient role queries
AndreGoepel.Marten.Identity.Http SetupRedirectMiddleware, CookieLoginMiddleware
AndreGoepel.Marten.Identity.Services ICurrentUserService / CurrentUserService

License

MIT

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 (1)

Showing the top 1 NuGet packages that depend on AndreGoepel.Marten.Identity:

Package Downloads
AndreGoepel.Marten.Identity.Blazor

Blazor Server UI components for AndreGoepel.Marten.Identity — login, registration, 2FA, passkeys, and user/role administration pages built with Radzen.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 65 6/26/2026
1.1.0-preview4 41 6/26/2026
1.1.0-preview3 42 6/26/2026
1.1.0-preview2 41 6/26/2026
1.1.0-preview1 47 6/26/2026
1.0.2 56 6/25/2026
1.0.1 109 6/13/2026
1.0.0 194 6/13/2026