identityserver-usermanagement
Configures user management and authentication flows for Duende IdentityServer, prioritizing passwordless methods.
Install
mkdir -p .claude/skills/identityserver-usermanagement && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/11539" && unzip -o skill.zip -d .claude/skills/identityserver-usermanagement && rm skill.zipInstalls to .claude/skills/identityserver-usermanagement
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Setting up Duende User Management with IdentityServer: passwordless authentication (OTP, TOTP, passkeys), storage configuration, user lifecycle, and migration from ASP.NET Identity.Key capabilities
- →Add user management to Duende IdentityServer projects
- →Set up passwordless authentication (OTP, TOTP, passkeys)
- →Configure storage providers (PostgreSQL, SQL Server, SQLite)
- →Integrate User Management with IdentityServer for claims delivery
- →Manage user profiles, roles, and groups
- →Migrate users from ASP.NET Identity
How it works
The skill integrates Duende User Management into IdentityServer by adding necessary NuGet packages and configuring services in `Program.cs` for passwordless authentication, storage, and claims mapping.
Inputs & outputs
When to use identityserver-usermanagement
- →Implementing passwordless login flows
- →Migrating existing users from ASP.NET Identity
- →Configuring PostgreSQL or SQL Server for IdentityServer
- →Setting up user roles and profile management
About this skill
User Management
When to Use This Skill
- Adding user management to a Duende IdentityServer project
- Setting up passwordless authentication (OTP, TOTP, passkeys)
- Configuring storage providers (PostgreSQL, SQL Server, SQLite)
- Integrating User Management with IdentityServer for claims and login/logout
- Managing user profiles, roles, and groups
- Migrating users from ASP.NET Identity
Core Principles
- Duende User Management is passwordless-first — OTP email/SMS is the default flow
- Requires
Duende.UserManagement.IdentityServer8NuGet package + .NET 10 - Storage is document-based (no EF migrations) but the schema is not auto-created — call
IStorageInstanceSchema.MigrateAsync()at startup or as a deployment step - Select the storage provider with
AddStorage(...)on the IdentityServer builder, not insideAddUserManagement(); OTP/authentication options go insideAddUserManagement(options => options.Authentication(...)) - Use
app.UseIdentityServer()(notUseAuthentication()separately)
Docs: https://docs.duendesoftware.com/identityserver/usermanagement
Setup
1. Add Packages
dotnet add package Duende.IdentityServer
dotnet add package Duende.UserManagement.IdentityServer8
dotnet add package Duende.Storage.Sqlite # or Duende.Storage.PostgreSql, Duende.Storage.MsSql
2. Configure Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddIdentityServer(options =>
{
options.UserInteraction.LoginUrl = "/Account/Login";
options.UserInteraction.LogoutUrl = "/Account/Logout";
})
.AddInMemoryClients(Config.Clients)
.AddInMemoryIdentityResources(Config.IdentityResources)
// Storage: select a Duende Storage provider on the IdentityServer builder
.AddStorage(storage => storage.AddSqlite(o => o.ConnectionString = "Data Source=users.db"))
// .AddStorage(storage => storage.AddPostgreSql()) // needs an NpgsqlDataSource registered in DI
// .AddStorage(storage => storage.AddMsSql(o => { })) // needs a CreateSqlConnection registered in DI
.AddUserManagement(options =>
{
// OTP delivery
options.Authentication(auth => auth.UseSmtpOtpDispatcher(smtp =>
builder.Configuration.GetSection("Smtp").Bind(smtp)));
});
builder.Services.AddRazorPages();
var app = builder.Build();
// Create/upgrade the database schema (development convenience; use a deployment step in production)
using (var scope = app.Services.CreateScope())
{
var schemaFactory = scope.ServiceProvider.GetRequiredService<IStorageInstanceSchemaFactory>();
var schema = await schemaFactory.GetStorageInstanceSchema(CancellationToken.None);
await schema.MigrateAsync(CancellationToken.None);
}
app.UseIdentityServer();
app.MapRazorPages();
app.Run();
3. OTP Dispatcher
Console (development): User Management ships no console dispatcher; implement IOtpDispatcher yourself:
using Duende.UserManagement.Authentication.Otp;
public class ConsoleOtpDispatcher : IOtpDispatcher
{
public bool CanDispatch(OtpAddress address) => true;
public Task DispatchAsync(OtpAddress address, PlainTextOtp otp, TimeSpan expiresAfter, CancellationToken ct)
{
Console.WriteLine($"OTP for {address}: {otp.Text}");
return Task.CompletedTask;
}
}
builder.Services.AddSingleton<IOtpDispatcher, ConsoleOtpDispatcher>();
SMTP (production):
.AddUserManagement(options => options.Authentication(auth => auth.UseSmtpOtpDispatcher(x =>
{
x.Host = "smtp.example.com"; // required
x.Port = 587; // default 1025
x.EnableSsl = true; // default true
x.FromEmail = "[email protected]"; // required
x.FromName = "MyApp"; // required
x.Domain = "app.example.com"; // optional, used in security warning
// optional: PlainTextTemplate, HtmlTemplate, SubjectTemplate
})));
Authentication Methods
| Method | Description | Setup |
|---|---|---|
| OTP (default) | One-time codes via email/SMS | IOtpDispatcher implementation |
| TOTP | Authenticator apps (RFC 6238) | Built-in, user enrollment required |
| Passkeys | WebAuthn/FIDO2 phishing-resistant | Built-in, browser support required |
| Passwords | Traditional username/password (PBKDF2) | Opt-in, not recommended as primary |
| External | OAuth 2.0 / OIDC federated login | Standard ASP.NET Core auth handlers |
| Recovery codes | Single-use backup codes | Auto-generated during 2FA setup |
IdentityServer Integration
AddUserManagement() is called on the IdentityServer builder — it automatically:
- Registers
IProfileServicefor claims delivery - Handles login/logout flows
- Maps user attributes to identity token claims
Claims Mapping
User profile attributes are mapped to claims based on requested scopes:
openid→subprofile→name,given_name,family_name, etc.email→email(email_verifiedis not in the built-in profile schema; add it withBuiltInSchemas.UserProfile.Extend(OidcStandardAttributes.EmailVerified)and set it, e.g.attributes.Set(AttributeCode.Create("email_verified"), true))
Custom attributes are available through custom identity resources.
Storage
User Management uses the Duende Storage layer (document-based, in a relational DB). Storage is selected with AddStorage(...) on the IdentityServer builder, not inside AddUserManagement. AddUserManagement(...) only maps the user-management data category to a storage instance.
| Provider | Package | Registration |
|---|---|---|
| SQLite | Duende.Storage.Sqlite | storage.AddSqlite(o => o.ConnectionString = "..."); AddSqliteInMemory() for tests only |
| PostgreSQL (recommended for production, native JSONB) | Duende.Storage.PostgreSql | storage.AddPostgreSql() with an NpgsqlDataSource singleton in DI; SchemaName option |
| SQL Server | Duende.Storage.MsSql | storage.AddMsSql(o => { }) with a CreateSqlConnection singleton in DI |
- No EF Core migrations, but the common storage schema must be created:
IStorageInstanceSchema.MigrateAsync(fromIStorageInstanceSchemaFactory.GetStorageInstanceSchema(ct)). It's idempotent (advisory locks on PostgreSQL). In production run it as a separate deployment step.CheckVersionAsyncreturnsIsCompatible/CurrentVersion/RequiredVersionfor a startup compatibility check. - Shared instance: if
AddStorage(...)already registered a provider for the default instance (withAddConfigurationStorage()/AddOperationalStorage()), callAddUserManagement(...)without registering the provider again; IdentityServer and User Management share the DB and schema (different entity types). Selecting a second provider for the same instance throwsInvalidOperationException. - Dedicated database:
var umInstance = StorageInstanceId.Create("user-management");+.AddStorage(umInstance, storage => storage.AddPostgreSql(sp => sp.GetRequiredKeyedService<NpgsqlDataSource>(umInstance.Value)))+.AddUserManagement(umInstance, um => { }). Migrate that instance explicitly:GetStorageInstanceSchema(umInstance, ct). - This page's storage covers only User Management data (profiles, authenticators, roles, groups); IdentityServer config/operational data uses whichever provider you chose (EF Core, Duende Storage, ...). See
identityserver-duende-storage. - With Spaces, User Management data is stored in the resolved space's pool by default (isolated users per space); see
identityserver-spaces.
Profile Schema
Profile attributes are defined by a schema (SchemaConfiguration, SchemaId.UserProfile). AddUserManagement(...) registers BuiltInSchemas.UserProfile (email [unique, required], name, given_name, family_name; each access returns a new mutable instance). With defaults, users register and log in by email.
// Extend (throws InvalidOperationException if an attribute/group code already exists)
var department = new AttributeDefinition
{
Code = AttributeCode.Create("department"),
AttributeType = new ScalarAttributeType(ScalarDataType.String),
Description = AttributeDescription.Create("The department the user belongs to.")
};
builder.Services.AddIdentityServer()
.AddUserManagement(_ => { })
.AddInMemoryDataExtensionSchemas([BuiltInSchemas.UserProfile.Extend(department)]);
Extend(attributes, groups)also addsAttributeGroups; attributes getGroupCode/Order(not unique; apply a secondary sort). There is no dedicated reorder API: build/replace the schema.- Replace: register a full
SchemaConfigurationwithSchemaId.UserProfile(e.g. login by a customusernameattribute); none of the built-in attributes remain unless re-added. A schema with the sameSchemaIdas the built-in always wins; registration order relative toAddUserManagementdoesn't matter; the last registered wins. - Runtime editing:
AddDynamicSchemas()gives youISchemaAdmin(get-modify-UpdateAsyncwith the version for optimistic concurrency). In that mode in-memory schemas (including the built-in profile) are not used or seeded;GetAsync(SchemaId.UserProfile)returns not-found until you create it. OidcStandardAttributes.*(e.g.MiddleName,Nickname) can be passed toExtend;Email/Name/GivenName/FamilyNameare already included.- Removing an attribute from the schema does not purge stored values (validated on write only).
IUserProfileSchemaAdminwas removed; useISchemaAdmin. profile.ToUpdate()returns a mutableAttributeValueCollectionfor read-modify-write withIUserProfileSelfService.TryUpdateAsync(subjectId, update.Validate(), ct).- Membership is managed through the single
IMembershipAdmin(replacesIRoleMembershipAdmin/IGroupMembershipAdmin) alongsideIRoleAdmin/IGroupAdmin.
Passkeys
`AddUserManagement(...
Content truncated.
When not to use it
- →When configuring storage outside `AddUserManagement()`
- →When using `UseAuthentication()` instead of `UseIdentityServer()`
- →When skipping `CreateIfNotExistsAsync()` for database schema creation
Limitations
- →The skill requires `Duende.UserManagement.IdentityServer8` NuGet package + .NET 10.
- →Storage configuration must be inside `AddUserManagement()` options.
- →The skill requires `app.UseIdentityServer()` for middleware.
How it compares
This skill provides a structured approach to integrating passwordless-first user management into Duende IdentityServer, simplifying complex configurations and migrations compared to manual setup.
Compared to similar skills
identityserver-usermanagement side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| identityserver-usermanagement (this skill) | 0 | 5mo | Review | Intermediate |
| azure-identity-dotnet | 1 | 7mo | Review | Beginner |
| azure-security-keyvault-keys-dotnet | 1 | 6mo | Review | Intermediate |
| csharp-developer | 43 | 6mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
azure-identity-dotnet
microsoft
Azure Identity SDK for .NET. Authentication library for Azure SDK clients using Microsoft Entra ID. Use for DefaultAzureCredential, managed identity, service principals, and developer credentials. Triggers: "Azure Identity", "DefaultAzureCredential", "ManagedIdentityCredential", "ClientSecretCredential", "authentication .NET", "Azure auth", "credential chain".
azure-security-keyvault-keys-dotnet
microsoft
Azure Key Vault Keys SDK for .NET. Client library for managing cryptographic keys in Azure Key Vault and Managed HSM. Use for key creation, rotation, encryption, decryption, signing, and verification. Triggers: "Key Vault keys", "KeyClient", "CryptographyClient", "RSA key", "EC key", "encrypt decrypt .NET", "key rotation", "HSM".
csharp-developer
zenobi-us
Expert C# developer specializing in modern .NET development, ASP.NET Core, and cloud-native applications. Masters C# 12 features, Blazor, and cross-platform development with emphasis on performance and clean architecture.
csharp-pro
sickn33
Write modern C# code with advanced features like records, pattern matching, and async/await. Optimizes .NET applications, implements enterprise patterns, and ensures comprehensive testing. Use PROACTIVELY for C# refactoring, performance optimization, or complex .NET solutions.
microsoft-code-reference
github
Look up Microsoft API references, find working code samples, and verify SDK code is correct. Use when working with Azure SDKs, .NET libraries, or Microsoft APIs—to find the right method, check parameters, get working examples, or troubleshoot errors. Catches hallucinated methods, wrong signatures, and deprecated patterns by querying official docs.
dotnet-architect
sickn33
Expert .NET backend architect specializing in C#, ASP.NET Core, Entity Framework, Dapper, and enterprise application patterns. Masters async/await, dependency injection, caching strategies, and performance optimization. Use PROACTIVELY for .NET API development, code review, or architecture decisions.