At the beginning of a project, user management might look like a database table, a registration form, and a login page. As real requirements appear, more questions follow: How should passwords be stored? What happens when someone forgets theirs? How many failed login attempts are allowed? How do administrator permissions differ from regular user permissions?
Each requirement introduces its own behavior and failure cases. Implementing these features from scratch also makes the team responsible for maintaining and correcting them.
ASP.NET Core Identity is Microsoft's framework for managing user accounts in ASP.NET Core applications. This article explores its features, the reasons to consider it, and the situations that call for a different solution.
Which Identity product are we discussing?
Two similar names can cause confusion:
| Name | Main purpose |
|---|---|
| ASP.NET Core Identity | Managing user accounts and related workflows within an ASP.NET Core application |
| Microsoft identity platform | Connecting applications to Microsoft's identity service using protocols such as OAuth 2.0 and OpenID Connect |
This article focuses on ASP.NET Core Identity: the framework that provides classes such as IdentityUser, UserManager, and SignInManager.
Using it does not inherently require an Azure account or signing in with a Microsoft account. Applications can store users in their own database and provide independent registration and login workflows.
What features does Identity provide?
Identity covers common parts of the user account lifecycle:
| Feature | Purpose |
|---|---|
| User management | Creating accounts, updating information, and managing user status |
| Password management | Hashing and verifying passwords, changing passwords, and applying validation rules |
| Email confirmation | Verifying access to the registered email address |
| Password recovery | Generating and validating password reset tokens |
| Account lockout | Restricting failed login attempts through appropriate configuration |
| Two-factor authentication | Adding a second verification step, such as an authenticator app code |
| Roles and claims | Maintaining information used in access decisions |
| External login | Connecting application accounts to providers such as Google and Microsoft |
Having these features available does not mean they are all enabled when a project is created. The required services, settings, and application flows must be configured.
For example, generating an email confirmation token does not send an email. Integrating an email delivery service and handling delivery failures remain part of the application implementation.
Why not build user management from scratch?
Suppose a login endpoint receives an email address and password, loads the user from the database, and verifies the password. That covers only part of the login process.
Other situations need decisions immediately:
- The user has not confirmed their email address.
- Failed login attempts have temporarily locked the account.
- Two-factor authentication is enabled.
- The user needs to change or reset their password.
- Account credentials must satisfy updated validation rules.
Identity provides existing components and contracts for these common workflows. This allows the team to spend more time on requirements specific to the product.
Using a library does not guarantee the security of the entire application. Configuration, correct API usage, and authorization over application data still require design and maintenance.
How do the main components fit together?
A few components form the foundation of working with Identity:
| Component | Responsibility |
|---|---|
IdentityUser |
The base model for user account information |
UserManager<TUser> |
Managing users, passwords, claims, and role membership |
SignInManager<TUser> |
Managing sign-in, sign-out, and related authentication steps |
RoleManager<TRole> |
Creating and managing roles |
| Stores | Reading and writing Identity information in the underlying storage system |
For example, creating an account through UserManager.CreateAsync includes the relevant validation and password processing in the account creation workflow.
Directly inserting a record into the users table is therefore not equivalent to using the standard account creation path.
Separating managers from stores also allows the persistence mechanism to change. Entity Framework Core is a common option, but it is not the only one. Custom stores are possible, with the additional responsibility of implementing and verifying their required contracts and behavior.
Authentication and authorization have different responsibilities
Authentication establishes who the user is.
Authorization determines what that user is allowed to do.
Suppose a customer signs in to an online store. Successful authentication does not give them permission to view every customer's orders.
Identity can manage roles and claims. ASP.NET Core authorization can then use that information, together with application rules, to control access.
For example, after configuring role services and assigning the appropriate role, an MVC action can be restricted:
[Authorize(Roles = "Admin")]
public IActionResult Dashboard()
{
return View();
}
This check evaluates role membership. An operation such as viewing a personal order also requires checking ownership of that particular order. Having the Customer role does not establish that the requested order belongs to the current user.
Account recovery is part of the core design
A user who forgets their password needs a defined recovery path. Identity provides tools to generate and validate password reset and email confirmation tokens.
A complete recovery experience involves additional responsibilities:
- Sending the link to the registered address
- Handling invalid or expired tokens
- Displaying appropriate messages
- Handling email service failures
For two-factor authentication, Identity supports time-based one-time passwords, or TOTP, with compatible apps such as Microsoft Authenticator and Google Authenticator.
The design should also account for losing access to the authenticator device. Adding a verification step without a recovery path can lock legitimate users out of their accounts.
Configuration alone does not implement the complete behavior
Identity provides settings for password rules, lockout duration, failed attempt limits, and sign-in requirements.
The application code must use those settings correctly.
For example, when using PasswordSignInAsync, the lockoutOnFailure parameter controls whether a failed password check counts toward account lockout.
A sign-in result also contains more information than success or failure. An account may be locked out, sign-in may not be allowed, or a second verification step may be required. Application code needs to handle those outcomes according to the product's workflow.
Reviewing an implementation therefore means checking the actual registration, login, recovery, and logout behavior alongside its configuration.
Is Identity the same as JWT?
Identity and JWT serve different purposes.
Identity provides account management and related workflows. JWT is a token format that can be used in certain authentication and authorization architectures.
Asking “Should we use Identity or JWT?” does not define a meaningful choice without first establishing the application's requirements. Identity might manage user accounts while another component handles standard token issuance.
Another important detail is that the built-in Identity API bearer tokens are not standard JWTs. This feature targets simpler scenarios and does not replace a full identity provider or OAuth and OpenID Connect server.
For browser-based applications, the Identity API documentation recommends cookies. The final choice should account for the client architecture, domains, and application communication requirements.
When is Identity a good fit?
Consider a booking application where users create accounts, update their profiles, and access application features through defined roles.
If the team wants to manage accounts and related workflows within its ASP.NET Core application, Identity is worth considering. Its existing components reduce the amount of repetitive infrastructure the team needs to implement, while still supporting customization.
If the requirement involves shared sign-in across several applications or integration with organizational accounts, identity architecture needs a broader assessment:
| Requirement | Option to investigate |
|---|---|
| Independent accounts for an ASP.NET Core application | ASP.NET Core Identity |
| Sign-in with Microsoft organizational accounts | Microsoft Entra ID and the Microsoft identity platform |
| A central service using OAuth 2.0 and OpenID Connect | An identity provider or protocol server that fits the requirements |
| Connecting an application to an organization's existing identity service | Integration with that service |
These options are not always mutually exclusive. For example, an identity server can use ASP.NET Core Identity to manage local users while taking responsibility for implementing protocols and issuing tokens.
What should we ask before choosing?
Start with account requirements and the application's trust boundaries:
- Will users create accounts in this product, or do they already have organizational identities?
- Is sign-in needed for one application or shared across several?
- Are the clients browsers, or are mobile applications and other services involved?
- Should our team be responsible for storing and managing account information?
- Are simple roles sufficient, or do access decisions depend on particular data and operations?
- How much capacity does the team have for support, account recovery, and identity infrastructure maintenance?
For an application that needs local account management, ASP.NET Core Identity can be a suitable starting point. Its value comes from providing common components that can be extended. The final choice should match the responsibilities the team intends to keep within the application.