Benday.Identity.CosmosDb.UI 3.2.0

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

Benday.Identity.CosmosDb.UI

Pre-built ASP.NET Core Identity UI pages for Azure Cosmos DB. One-line setup with AddCosmosIdentityWithUI() gives you login, registration, password reset, email confirmation, passkey management, account management, and a full admin dashboard — all backed by Cosmos DB.

Built on top of Benday.Identity.CosmosDb and Benday.CosmosDb.

Included Pages

Authentication

Page Path Description
Login /Account/Login Username/password + passkey sign-in
Logout /Account/Logout Sign-out
Access Denied /Account/AccessDenied Unauthorized access page
Register /Account/Register Self-registration (can be disabled)
Forgot Password /Account/ForgotPassword Request a password reset email
Reset Password /Account/ResetPassword Reset password via emailed token
Confirm Email /Account/ConfirmEmail Email confirmation via emailed link

Account Management

Page Path Description
My Account /Account Hub page linking to all account features
Edit Profile /Account/EditProfile Update first name, last name, phone number
Change Password /Account/ChangePassword Authenticated password change
Manage Passkeys /Account/ManagePasskeys Add/remove passkeys for passwordless sign-in

Admin Dashboard (requires CosmosIdentityAdmin policy)

Page Path Description
Admin Dashboard /Admin Hub page for all admin features
Users /Admin/Users Search and list users
Create User /Admin/Users/Create Create a new user account
Edit User /Admin/Users/Edit?id= Edit profile, lock/unlock, reset password, delete
User Roles /Admin/Users/Roles?id= Assign/remove roles for a user
User Claims /Admin/Users/Claims?id= Assign/remove claims using claim definitions
Roles /Admin/Roles Create and delete security roles
Claim Definitions /Admin/ClaimDefinitions Define claim types and allowed values
Edit Claim Def /Admin/ClaimDefinitions/Edit?id= Create/edit a claim definition

Quick Start

dotnet add package Benday.Identity.CosmosDb.UI
using Benday.Identity.CosmosDb.UI;
using Benday.CosmosDb.Utilities;

var cosmosConfig = builder.Configuration.GetCosmosConfig();

builder.Services.AddCosmosIdentityWithUI(cosmosConfig);
builder.Services.AddRazorPages();

// ...

app.UseAuthentication();
app.UseAuthorization();
app.MapRazorPages();

Customization

builder.Services.AddCosmosIdentityWithUI(cosmosConfig,
    options =>
    {
        options.CookieName = "MyApp.Auth";
        options.CookieExpiration = TimeSpan.FromDays(30);
        options.AllowRegistration = false;       // disable self-registration
        options.AdminRoleName = "SuperAdmin";    // custom admin role
        options.RequireConfirmedEmail = true;     // require email confirmation
    },
    identity =>
    {
        identity.Password.RequiredLength = 12;
        identity.Lockout.MaxFailedAccessAttempts = 3;
    });

All Options

Option Default Description
UsersContainerName CosmosConfig.ContainerName Container for user documents
RolesContainerName CosmosConfig.ContainerName Container for role documents
CookieName "Identity.Auth" Authentication cookie name
LoginPath "/Account/Login" Login page path
LogoutPath "/Account/Logout" Logout page path
AccessDeniedPath "/Account/AccessDenied" Access denied page path
CookieExpiration 14 days Cookie expiration time
SlidingExpiration true Whether to use sliding expiration
AllowRegistration true Whether self-registration is allowed
AdminRoleName "UserAdmin" Role name required for admin pages
RequireConfirmedEmail false Whether email confirmation is required before sign-in
ShowRememberMe true Whether to show "Remember me" checkbox on login
RememberMeDefaultValue true Default checked state of "Remember me"
FromEmailAddress "" "From" address used by SmtpCosmosIdentityEmailSender
EnablePasskeys true Whether passkey (WebAuthn) authentication is enabled
PasskeyServerDomain null WebAuthn Relying Party ID (domain)
ClaimDefinitionsContainerName CosmosConfig.ContainerName Container for claim definition documents

Password Reset & Email Confirmation

These flows require a working email sender. By default a no-op sender is registered (emails are silently skipped).

Option 1: Built-in SMTP sender

builder.Services.AddSingleton(new SmtpClient("smtp.yourserver.com")
{
    Port = 587,
    Credentials = new NetworkCredential("user", "password"),
    EnableSsl = true
});

// Register BEFORE AddCosmosIdentityWithUI (it uses TryAddSingleton)
builder.Services.AddSingleton<ICosmosIdentityEmailSender, SmtpCosmosIdentityEmailSender>();

builder.Services.AddCosmosIdentityWithUI(cosmosConfig,
    options => { options.FromEmailAddress = "noreply@yourapp.com"; });

Option 2: Custom sender (SendGrid, SES, etc.)

Implement ICosmosIdentityEmailSender and register it before AddCosmosIdentityWithUI():

public class SendGridEmailSender : ICosmosIdentityEmailSender
{
    public async Task SendEmailAsync(string email, string subject, string htmlMessage)
    {
        // Your implementation here
    }
}

builder.Services.AddSingleton<ICosmosIdentityEmailSender, SendGridEmailSender>();
builder.Services.AddCosmosIdentityWithUI(cosmosConfig);

Blazor: RedirectToLogin

<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(MainLayout)">
    <NotAuthorized>
        <RedirectToLogin />
    </NotAuthorized>
</AuthorizeRouteView>

Seed Admin User

if (args.Contains("--seed-admin"))
{
    await CosmosIdentitySeeder.SeedAdminUserInteractive(app.Services);
    return;
}

Then run: dotnet run -- --seed-admin

Admin Pages

The admin dashboard at /Admin is protected by the CosmosIdentityAdmin authorization policy (requires the role specified by AdminRoleName, default "UserAdmin"). The CosmosIdentitySeeder automatically assigns this role when seeding.

The admin section includes full user management (create, edit, lock/unlock, reset password, delete), role management, claim definition management (with optional allowed values), and user role/claim assignment.

Navigation flow: Navbar → My Account (/Account) → Admin Dashboard (shown only for admins) → Users / Roles / Claim Definitions

License

MIT License - see LICENSE file for details.

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

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
3.2.0 38 3/13/2026
3.1.2 77 3/10/2026
3.1.1 77 3/10/2026
3.1.0 81 3/9/2026
3.0.0 90 2/27/2026
2.2.0 96 2/11/2026
2.1.0 90 2/9/2026
2.0.0 110 2/5/2026

v3.2.0 - Fixed some pretty massive bugs in the data access layer where partition keys were being ignored; Made the root partition key configurable via options and also default to 'SYSTEM';      
v3.1.2 - Fix passkey 400 errors: add anti-forgery token to all WebAuthn fetch POST requests.
v3.1.1 - Fix admin policy constant usage, consolidate admin pages under /Admin, rename MyAccount route to /Account.
v3.1.0 - Added My Account hub page, Edit Profile page, and full admin dashboard with user management (create, edit, lock/unlock, reset password, delete), role management (CRUD), claim definition management (CRUD with allowed values), user role assignment, and user claim assignment pages. All admin pages protected by CosmosIdentityAdmin policy.
v3.0.0 - BREAKING: Target net10.0 only (drop net9.0). Added passkey (WebAuthn/FIDO2) login button on login page, ManagePasskeys page for passkey registration and management.
v2.2.0 - Added net10.0 target framework (multi-targets net9.0 and net10.0). Added NuGet package README.
v2.1.0 - Added Register, ChangePassword, ForgotPassword, ResetPassword, ConfirmEmail pages. Added admin User List and Edit User pages with role/claim management and account lockout. Added NoOpCosmosIdentityEmailSender, token providers, and CosmosIdentityAdmin authorization policy.
v2.0.0 - BREAKING: AddCosmosIdentity() moved to core Benday.Identity.CosmosDb package. Use AddCosmosIdentityWithUI() for the full UI experience. CosmosIdentityOptions and CosmosIdentitySeeder also moved to core package.