Skip to content
Introducing the next era of Duende IdentityServer. Read our CEO’s announcement

Authentication Flows Overview

Duende User Management supports multiple authentication flows, each suited to different use cases and security requirements. This page summarizes all available flows and helps you pick the right one.

Passwordless authentication using temporary codes sent via email or SMS.

Key Characteristics:

  • No password storage required
  • Code sent to the user’s registered email address or phone number
  • Time-limited verification codes
  • Auto-registration on first login

Best For:

  • Consumer applications wanting a passwordless experience
  • Quick user onboarding
  • Applications with email or SMS delivery infrastructure
  • Low-friction authentication

Two-factor authentication using authenticator apps that generate time-based codes.

Key Characteristics:

Best For:

  • High-security applications
  • Adding a second factor on top of password authentication
  • Applications requiring Multi-Factor Authentication (MFA) compliance
  • User accounts containing sensitive data

Traditional username and password authentication.

Key Characteristics:

  • Users create and manage their own passwords
  • Password hashing and secure storage
  • Configurable password complexity requirements
  • Foundation for adding two-factor authentication

Best For:

  • Enterprise applications
  • Regulated industries
  • Applications requiring offline authentication
  • Scenarios where external providers are not suitable

Federated authentication using external identity providers (social login, enterprise SSO).

Key Characteristics:

  • OAuth 2.0 / OpenID Connect integration
  • No password storage in your application
  • Auto-registration from external provider profiles
  • Multiple external authenticators per user

Best For:

  • Consumer-facing applications
  • Social or collaborative platforms
  • Reducing password management burden
  • Using established identity providers (Google, Microsoft, etc.)

Phishing-resistant, device-bound authentication using the FIDO2/WebAuthn standard.

Key Characteristics:

  • Cryptographic key pair stored on the user’s device
  • Phishing-resistant by design; credentials are bound to the origin
  • Supports biometric and hardware security key authenticators
  • No shared secrets transmitted over the network

Best For:

  • Highest-security applications
  • Applications targeting phishing-resistant authentication
  • Modern consumer and enterprise applications
  • Compliance scenarios requiring strong authentication

Backup authentication using single-use codes generated when two-factor authentication is enabled.

Key Characteristics:

  • Single-use codes for account recovery
  • Generated when Two-Factor Authentication (2FA) is first enabled
  • Cryptographically secure
  • Alternative when the primary 2FA method is unavailable

Best For:

  • Backup for TOTP authentication
  • Account recovery scenarios
  • Device loss or replacement
  • Emergency access

FlowRequires PasswordUser ExperienceSecurity LevelNetwork Required
OTPNoSimple, passwordlessMediumYes (to receive code)
TOTPYes*Two-stepHighNo
PasswordsYesTraditionalMediumNo
ExternalNoFamiliar (social/SSO)Medium-HighYes (for auth)
PasskeysNoBiometric / hardware keyVery HighNo
Recovery CodesNoEmergency onlyMediumNo

* TOTP is typically used as a second factor on top of password authentication.

OTP vs Password vs External Authentication

Section titled “OTP vs Password vs External Authentication”
AspectOTPPasswordExternal Auth
User MemoryNothing to rememberMust remember passwordNothing to remember
Offline SupportNoYesNo
SecurityChannel-dependentStrength-dependentProvider-dependent
User FrictionCheck email or SMSType passwordClick button
InfrastructureEmail or SMS providerPassword hashingExternal identity provider
AspectTOTPSMS
SecurityHighMedium
OfflineYesNo
Phishing resistanceHighLow
SIM swappingNot vulnerableVulnerable
CostFreeSMS costs
SetupRequires authenticator appWorks with any phone

Recommended: External + Optional TOTP

  • Users sign in with familiar social accounts (Google, Microsoft, etc.)
  • Optional TOTP for users wanting extra security
  • Minimal friction for new users

Alternative: OTP

  • Fully passwordless experience
  • Simple email-based login
  • No external provider dependencies

Recommended: Password + TOTP

  • Traditional password authentication users expect
  • Mandatory TOTP for compliance requirements
  • Recovery codes for account recovery

Alternative: External (OpenID Connect (OIDC))

  • Integrate with a corporate identity provider
  • Single sign-on experience
  • Centralized access management

Recommended: Passkeys

  • Phishing-resistant by design
  • No shared secrets
  • Pair with TOTP as a fallback and recovery codes for emergency access

Alternative: Password + Mandatory TOTP

  • Strong two-factor authentication
  • Recovery codes for emergency access
  • Audit-friendly authentication trail

Recommended: OTP or External

  • Fast to implement
  • No password management needed
  • Good user experience out of the box

User Management lets you combine multiple flows in a single application. A common pattern is OTP for initial registration, TOTP as an optional second factor, and recovery codes as a backup.

Authenticate with a password first, then check whether the user has a TOTP authenticator enrolled. Passwords can also expire; when they do, TryAuthenticateAsync returns PasswordAuthenticationResult.Expired so you can redirect the user to a password-change page. See the passwords page for details on configuring expiry.

// Primary authentication with password
var result = await passwordAuth.TryAuthenticateAsync(
AttributeCode.Create("email"),
email,
NonValidatedPassword.Create(password),
ct);
switch (result)
{
case PasswordAuthenticationResult.Success success:
// Check if user has 2FA enabled
var user = await userSelfService.TryGetUser(success.UserSubjectId, ct);
if (user?.TotpDeviceNames.Count > 0)
{
// Require TOTP verification
return RedirectToPage("/LoginWith2FA");
}
break;
case PasswordAuthenticationResult.Expired expired:
// The user's password has expired; redirect them to set a new one
return RedirectToPage("/ChangePassword", new { userId = expired.UserSubjectId });
default:
// Authentication failed
return;
}

Upgrade authentication strength based on the sensitivity of the requested action:

// Allow basic actions with OTP
if (User.FindFirst("amr")?.Value == "otp")
{
// Basic authenticated actions
}
// Require TOTP for sensitive actions
if (User.FindFirst("amr")?.Value == "mfa")
{
// High-security actions
}

Security considerations for each flow are covered on their respective pages. For cross-cutting topics (data protection key persistence, password hashing parameters, and throttling configuration) see the dedicated page: