MongoFlow.Identity
1.0.0-beta.7
dotnet add package MongoFlow.Identity --version 1.0.0-beta.7
NuGet\Install-Package MongoFlow.Identity -Version 1.0.0-beta.7
<PackageReference Include="MongoFlow.Identity" Version="1.0.0-beta.7" />
<PackageVersion Include="MongoFlow.Identity" Version="1.0.0-beta.7" />
<PackageReference Include="MongoFlow.Identity" />
paket add MongoFlow.Identity --version 1.0.0-beta.7
#r "nuget: MongoFlow.Identity, 1.0.0-beta.7"
#:package MongoFlow.Identity@1.0.0-beta.7
#addin nuget:?package=MongoFlow.Identity&version=1.0.0-beta.7&prerelease
#tool nuget:?package=MongoFlow.Identity&version=1.0.0-beta.7&prerelease
MongoFlow.Identity
A MongoDB provider for ASP.NET Core Identity, built on MongoFlow. Users and roles are stored in a MongoFlow vault, so its query filters, features and interceptors apply to them like to any other collection. It ships with MongoFlow, at the same version.
Installation
dotnet add package MongoFlow.Identity --prerelease
Usage
Derive the app's vault from IdentityMongoVault, register it, and call AddMongoFlowStores after AddRoles:
public sealed class AppVault : IdentityMongoVault;
services.AddMongoVault<AppVault>(vault => vault.UseDatabase("app"));
services.AddIdentityCore<MongoUser>()
.AddRoles<MongoRole>()
.AddMongoFlowStores<AppVault>();
The vault has three collections, Users, Roles and UserTokens, named after their properties unless the vault's
configuration names them. A user is one document, with its claims, logins, role ids and passkeys inside; tokens are
documents of their own.
Your own users, roles or keys
public sealed class AppUser : MongoUser
{
public string? DisplayName { get; set; }
}
public sealed class AppRole : MongoRole
{
public string? Description { get; set; }
}
public sealed class AppVault : IdentityMongoVault<AppUser, AppRole, ObjectId>;
IdentityMongoVault<TUser> and IdentityMongoVault<TUser, TKey> cover the cases with plain roles. The driver fills in
a missing ObjectId when a user, role or token is created. With string keys, set users' and roles' ids yourself;
tokens, which the store creates, get an ObjectId string. With another key type, set the ids yourself, and register an
id generator for it with BsonSerializer.RegisterIdGenerator for tokens.
Switching a feature off
The managers AddMongoFlowStores registers can make a copy whose reads and writes have a vault feature switched off,
such as to reach every tenant's users, or deleted ones:
var allTenants = userManager.Without(MultiTenancyFeature.Key);
var user = await allTenants.FindByEmailAsync(email);
var deletedRoles = roleManager.Without(SoftDeleteFeature.Key);
They take the place of Identity's own managers. A manager of the app's own, registered with AddUserManager or
AddRoleManager, is kept instead, and can't switch features off.
Concurrency
Updates and deletes of users and roles apply only while the stored ConcurrencyStamp is the one read, and an update
renews it, as Identity's Entity Framework store does: one made after another request changed the user fails with
ConcurrencyFailure, rather than overwriting the other's change. So does one made while another request's transaction
is changing the same user or role, which MongoDB rejects as a write conflict. Deleting a user deletes its tokens too.
More
- MongoFlow's docs: the vault, its configuration, features and interceptors, which apply to Identity's collections like to any other.
- The changelog: what changed since 0.2.
- The samples keep accounts in an Identity
vault that soft-deletes users, and restore one through
Without(SoftDeleteFeature.Key).
| 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. net11.0 is compatible. |
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.12)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Diagnostics (>= 10.0.12)
- Microsoft.Extensions.Identity.Stores (>= 10.0.12)
- Microsoft.Extensions.Logging (>= 10.0.12)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- MongoDB.Driver (>= 3.12.0)
- MongoFlow (>= 1.0.0-beta.7)
- Prest (>= 0.2.1)
- Semver (>= 3.0.0)
-
net11.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.12)
- Microsoft.Extensions.Diagnostics (>= 10.0.12)
- Microsoft.Extensions.Identity.Stores (>= 10.0.12)
- Microsoft.Extensions.Logging (>= 10.0.12)
- MongoDB.Driver (>= 3.12.0)
- MongoFlow (>= 1.0.0-beta.7)
- Prest (>= 0.2.1)
- Semver (>= 3.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-beta.7 | 33 | 10/6/2026 |
| 1.0.0-beta.6 | 38 | 10/6/2026 |
| 1.0.0-beta.5 | 45 | 10/4/2026 |
| 1.0.0-beta.4 | 48 | 10/3/2026 |
| 1.0.0-beta.3 | 46 | 10/3/2026 |
| 1.0.0-beta.2 | 45 | 10/3/2026 |
| 1.0.0-beta.1 | 53 | 10/2/2026 |
| 0.2.8 | 4,672 | 1/10/2026 |
| 0.2.7 | 286 | 1/5/2026 |
| 0.2.6 | 198 | 12/26/2025 |
| 0.2.5 | 222 | 12/26/2025 |
| 0.2.4 | 224 | 12/25/2025 |
| 0.2.3 | 224 | 12/25/2025 |
| 0.2.2 | 711 | 9/27/2025 |
| 0.2.1 | 2,150 | 3/16/2025 |
| 0.2.0 | 697 | 1/12/2025 |
| 0.2.0-beta.0 | 235 | 12/19/2024 |
| 0.1.16 | 240 | 12/17/2024 |
| 0.1.15 | 306 | 12/2/2024 |
| 0.1.14 | 196 | 12/1/2024 |