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
<PackageReference Include="AndreGoepel.Marten.Identity" Version="1.1.0" />
<PackageVersion Include="AndreGoepel.Marten.Identity" Version="1.1.0" />
<PackageReference Include="AndreGoepel.Marten.Identity" />
paket add AndreGoepel.Marten.Identity --version 1.1.0
#r "nuget: AndreGoepel.Marten.Identity, 1.1.0"
#:package AndreGoepel.Marten.Identity@1.1.0
#addin nuget:?package=AndreGoepel.Marten.Identity&version=1.1.0
#tool nuget:?package=AndreGoepel.Marten.Identity&version=1.1.0
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
SetupRedirectMiddlewareas the authoritative gate. Once an administrator holds theAdministratorrole, the middleware redirects/Setupaway 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
/Setuppage 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
/Setupredirect 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 | 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
- AndreGoepel.Marten.Identity.Abstractions (>= 1.1.0)
- Marten (>= 9.10.0)
- Marten.AspNetCore (>= 9.10.0)
- Quartz.Extensions.Hosting (>= 3.18.1)
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 |