Authentication and authorization are complicated, and it is risky to try and implement them yourself. Use this rule as a guide on choosing the right service or framework for your situation.
Choosing the right authentication and authorization approach for your situation can be tricky. It is a multi-faceted problem with many variables, and what seems like the right choice in one situation may not be in the other.
Without the answers to these questions, it will be difficult to choose the right option. With the answers to these questions, you can use the tips and flow chart below as a guide to help you choose the right solution.
Most applications require some form of authentication, and it's often as simple as providing a secure way for users to log in and ensure that unauthenticated users don't get access to protected resources. However, it's not uncommon to require some logic to be executed as part of the authentication process. Some examples might include:
Note that some of the options listed below support or include the features listed above, and these may be configurable directly rather than needing additional code or logic to support. These usually come with additional costs. When you need one of these that is not provided "out-of-the box", you need to build this yourself. Most of the options listed here provide a way to inject custom arbitrary logic into the authentication process, but they have different ways of achieving this and varying limitations.
Each project is different, and you will need to consider your individual needs and circumstances when choosing how to implement identity and authentication in your solution. There are countless options available for authentication, but the chart below can provide a guide for some of the major decisions, and help you narrow down to some of the relevant options. Use this to get started and be sure to consider all the other information in this rule before making a decision.
flowchart
Start(["Start"]) --> CustomLogic{"Need Custom/\nComplex Logic?"}
CustomLogic -->|"Yes"| IdentityServer(["IdentityServer"])
CustomLogic -->|"No"| AppType{"Application Type?"}
AppType -->|"Internal (Intranet)"| Kerberos{"Need Kerberos/\nAD Integration?"}
AppType -->|"External (B2B/B2C)"| Hosting{"Hosting?"}
KerberosHosting{"Hosting?"} -->|"On-Premises"| SingleApp{"SSO?"}
KerberosHosting -->|"Cloud"| Ecosystem{"Existing Ecosystem/\nPreference?"}
Kerberos -->|"No"| KerberosHosting
Kerberos -->|"Yes"| OnPremAD(["On-Premises Active Directory"])
Hosting -->|"On-Premises"| Kerberos
Hosting -->|"Cloud"| Ecosystem
Ecosystem --> Entra(["Entra ID"])
Ecosystem --> Auth0(["Auth0"])
Ecosystem --> WorkOS(["WorkOS"])
Ecosystem --> BetterAuth(["Better Auth"])
Ecosystem --> OtherIDP(["Other Cloud IDP"])
SingleApp -->|"Yes"| IdentityServer
SingleApp -->|"No"| NETCORE(["ASP.NET Core Identity"])Figure: Authentication Selection
Your situation is unique, and every application's requirements are different. These tips can help you identify options to consider for your solution.
In addition to the main points discussed above, the following considerations could also be relevant to your decision.
While there are too many options to cover them all, this chart will help you narrow your choice to a few key options. Some detail about these options is provided below.
ASP.NET Core has some built-in identity functionality that allows you to create users and roles, and manage the security of your web applications. It is extremely capable and can be used to support a broad number of scenarios. However, it is intended for use in simple web applications, and while it can be extended to support other clients, you will need to build and wire up a lot of the UI for these scenarios yourself.
Identity Endpoints were introduced in .NET 8 and have continued to evolve in .NET 9 and .NET 10, allowing you to support even more scenarios (like using API endpoints to exchange a username and password for an access token).
However, the most important consideration is that this approach is intended for use in a single, standalone application.
Your identity store will be limited to this one application, so your users will not be able to share this identity across multiple applications.
✅ Advantages:
❌ Disadvantages:
Use this option if...
Identity Server is a source-available, OIDC compliant solution from Duende that is built on top of ASP.NET Core. It is licensed under the Duende Software License, which is free via the Community Edition for qualifying small companies (less than $1M projected annual revenue and less than $3M in capital). Production use by larger organizations requires a paid license (Starter at $1,500/year, Business at $9,000/year, or Enterprise at $20,000/year). It has extensive support for a number of authentication and authorization scenarios and supports multiple external identity providers out of the box (meaning it can easily integrate with Microsoft, Google, etc. accounts). IdentityServer extends ASP.NET Core Identity to natively support multiple client types (e.g. web, mobile, machine-to-machine, etc.) and can be used as a single identity across multiple applications.
IdentityServer provides unmatched flexibility and control over your authentication process. While some other options provide ways to execute custom logic as part of a login process, for anything beyond the most basic of scenarios, IdentityServer will be orders of magnitude easier to implement.
By running your own IdentityServer, you can provide and manage your own SSO IDP across multiple applications.
✅ Advantages:
❌ Disadvantages:
Use this option if...
OpenIddict is an open-source framework designed for ASP.NET Core that facilitates the implementation of OpenID Connect (OIDC) servers. Whereas IdentityServer provides a full solution, OpenIddict provides a foundation upon which you can build your own IdentityServer-like product.
Out of the box, it provides support for all of the core OIDC functionality (i.e. granting and validating tokens), but does not provide any UI or user management, or any way to manage clients, resources, scopes etc.
Because of this, it provides even more flexibility than IdentityServer; but this comes at the cost of taking on a significant implementation overhead yourself (it's like saying buying a bunch of car parts provides more flexibility than buying a car).
✅ Advantages:
❌ Disadvantages:
Use this option if...
Active Directory has been the de facto enterprise identity store for most of the world for decades. While most organizations are moving to the cloud these days, many still use AD as it provides a lot of additional capability and is integrated with most of their existing enterprise applications. AD supports multiple authentication protocols, including:
✅ Advantages:
❌ Disadvantages:
Use this option if...
Microsoft Entra is Microsoft's cloud-based identity and network/access management platform and provides strong identity features such as MFA and self-service password recovery, as well as access policies and anomaly detection. Being cloud-based, it can authenticate users anywhere in the world (rather than just on-premises on corporate computers).
✅ Advantages:
❌ Disadvantages:
Use this option if...
Microsoft Entra External ID has replaced AAD B2C. It's part of the Microsoft Entra family and includes all the benefits it provides, as well as enabling consumer-friendly features. These include integration with external identity providers and more flexible/customizable login flows. It is well-tailored to support authentication, and while it can be extended to support additional capabilities, this requires custom development.
✅ Advantages:
❌ Disadvantages:
Use this option if...
Auth0 is a commercial identity product aimed at developers. It is cloud-hosted and offers out-of-the-box functionality for user signup and login, self-service password recovery, OIDC compliance, external auth integration, and other consumer and user-friendly features. MFA is supported out of the box, and significant sophisticated functionality is available on the paid tiers.
✅ Advantages:
❌ Disadvantages:
Use this option if...
Okta is a commercial identity product aimed at enterprises. Many enterprise-centric software products, for example, Salesforce, have Okta connectors. Okta is intended to bridge the gap between enterprise authentication (such as AD) and modern software and SaaS products.
✅ Advantages:
❌ Disadvantages:
Use this option if...
Keycloak is an open-source identity and access management solution created in 2014. Governed by the Cloud Native Computing Foundation (CNCF) as an incubating project since April 2023, it provides enterprise-grade authentication and authorization capabilities through OIDC/OAuth 2.0/SAML SSO, identity brokering, and social logins.
✅ Advantages:
❌ Disadvantages:
Use this option if...
Better Auth is a comprehensive, framework-agnostic authentication framework for TypeScript that emerged in 2024 as the spiritual successor to NextAuth.js / Auth.js. In 2025, Auth.js (formerly NextAuth.js) was handed over to the Better Auth team for ongoing maintenance, consolidating the JavaScript/TypeScript open-source auth ecosystem under one roof. Better Auth has become one of the most widely adopted authentication solutions in the TypeScript ecosystem, backed by Y Combinator, Peak XV (formerly Sequoia), and a $5M seed round. It is self-hosted by default, fully open-source (MIT), and built from the ground up with end-to-end TypeScript type safety in mind.
Unlike IdentityServer (which targets .NET), Better Auth is designed for JavaScript and TypeScript stacks, including Next.js, SvelteKit, Nuxt, Astro, Express, Hono, and more. It also provides plug-and-play integrations for mobile and desktop: the official @better-auth/expo plugin adds authentication to Expo (React Native) apps for both iOS and Android, while the @better-auth/electron plugin (added in v1.5) handles the full OAuth flow for Electron desktop apps, including opening the system browser, exchanging authorization codes via custom protocol, and managing cookies securely. It ships with email/password auth, 2FA (TOTP/SMS), organisation/team management, and an extensible plugin system out of the box, without requiring third-party packages for common scenarios. If you are coming from NextAuth.js, an official migration guide is provided.
Better Auth includes 40+ pre-configured social login providers out of the box, including Google, GitHub, Apple, Discord, Microsoft, Facebook, Twitter/X, GitLab, Spotify, Twitch, LinkedIn, Slack, Dropbox, and more. Any OAuth2 or OIDC-compliant provider can also be added through the Generic OAuth plugin.
Better Auth uses traditional cookie-based server-side session management, where the session is stored in the database and a secure, httpOnly cookie is sent to the client. This means tokens are never exposed to the browser, reducing the attack surface for XSS and token theft compared to JWT-in-localStorage approaches. This architecture aligns well with the Backend for Frontend (BFF) security pattern and is well-suited for modern full-stack frameworks like Next.js, SvelteKit, and Nuxt where the server and client work closely together.
The project is actively maintained with frequent releases (v1.5 shipped 600+ commits, 70 new features, and 200 bug fixes), a growing community, and stewardship of the Auth.js project.
✅ Advantages:
❌ Disadvantages:
Use this option if...
WorkOS is a commercial, cloud-hosted identity platform designed primarily for B2B SaaS applications that need enterprise-grade authentication. Its flagship product, AuthKit, provides a hosted authentication UI and API covering the full range of modern auth needs — from simple email/password to Enterprise SSO — with a developer-first approach and one of the most generous free tiers available.
WorkOS is particularly well-suited to SaaS products that need to support enterprise customers with SSO requirements. It offers per-connection SSO pricing and a built-in Admin Portal that lets customers self-serve their own identity configuration, removing support burden from your team.
✅ Advantages:
❌ Disadvantages:
Use this option if...
It is entirely possible to create a users table and a roles table in your database and create and manage users yourself.
✅ Advantages:
❌ Disadvantages:
Use this option if...
External applications are B2B or B2C applications that are intended for consumption outside of your organization.
Scenario:
Your choices:
✅ Figure: Good example - The chosen solution meets the requirements and is highlighted as per [Do you manage up?](/do-you-manage-up)
For internal applications (referred to as "intranet applications" by Microsoft), the requirements might be different to externally facing applications. For example, they are more likely to be hosted on-premises (rare these days), or may need to use Windows Integrated Authentication (also rare these days, but provides a wonderful UX).
Scenario:
Your choices:
✅ Good example - The chosen solution meets the requirements without adding unnecessary additional costs
Notes: