Identity — AddIdentity Without RoleManager — Digitteck
Identity — AddIdentity Without RoleManager
dotnet·27 June 2020·3 min read

Identity — AddIdentity Without RoleManager

ASP.NET Identity provides two built-in extension methods for registering identity services:

  • AddIdentity<TUser, TRole> — adds UserManager, SignInManager, and RoleManager
  • AddIdentityCore<TUser> — adds only the UserManager

To include the SignInManager while excluding the RoleManager, you compose the pieces manually — just three lines of code. Here's what each built-in method registers:

AddIdentity source showing all registered services
AddIdentityCore source showing minimal services

The Final Composition

Start from AddIdentityCore and add back the missing pieces — SignInManager and default token providers:

Final identity registration without RoleManager

AddSignInManager() registers the HttpContextAccessor, ISecurityStampValidator, and ITwoFactorSecurityStampValidator:

AddSignInManager internals

AddDefaultTokenProviders() registers the standard data protection and TOTP token providers:

AddDefaultTokenProviders internals

Finally, AddUserStore registers the custom store implementation required by UserManager:

AddUserStore registration

If configuring Identity to protect personal data (IdentityServer normalizes usernames and emails), you also need to implement ILookupProtector, ILookupProtectorKeyRing, and IPersonalDataProtector. For distributed deployments, ensure the key store is shared across instances — not on local disk.

Tags

.NETASP.NET CoreIdentity
digitteck

© 2026 Digitteck