Upgrade to 4.0Changelog

3.x facade, kept for compatibility

AddAuthEndpoints and MapAuthEndpoints keep the 3.4.1 options, the AuthEndpointsSignIn values, and the /identity, /account, and /auth routes.

AddAuthEndpoints and MapAuthEndpoints are the 3.x facade. They are not obsolete. Names, options, AuthEndpointsSignIn, EmailCode.Enabled, and the /identity, /account, and /auth routes stay at 3.4.1. New hosts that want one password session use Password auth. Do not call both facades in one host.

builder.Services.AddAuthEndpoints<AppUser, AppDbContext>(options =>
{
    options.Passkeys.ServerDomain = "example.com";
});

app.UseAuthEndpoints();
app.MapAuthEndpoints<AppUser>();

Identity bearer is AddAuthEndpoints<AppUser, AppDbContext>(AuthEndpointsSignIn.IdentityBearer, ...). JWT on this facade is options.Jwt.Enabled = true plus Jwt.Configure. Passkeys are on until Passkeys.Enabled is false. Email-code sign-in is off until EmailCode.Enabled is true.

AddPasswordAuth<TUser, TRole, TContext> registers Identity roles before the EF stores. The three-type AddAuthEndpoints<TUser, TRole, TContext> overload is unchanged. Your DbContext must be IdentityDbContext<TUser, TRole, TKey> or equivalent. Do not chain .AddRoles<TRole>() after the two-type overload.

The changes that do apply to this facade are in Upgrade to 4.0. Password login, JWT POST /create failure text, and email-code verify stay on the 3.4.1 handlers, apart from those exceptions. POST and DELETE /manage/password stay unmapped here. The password facade maps both.

MapBearerAuthEndpoints maps no CSRF token route. On this facade, Identity bearer omits antiforgery on POST /account/passkeys/requestOptions, POST /account/passkeys/register/options, POST /account/passkeys/register, and POST /account/passkeys/login. The cookie facade still requires it on those routes, and GET /identity/csrfToken issues the token. Signed-in passkey changes require the token on both facades. The Identity ceremony state lives in the TwoFactorUserIdScheme cookie (Identity.TwoFactorUserId). That cookie is single-use state, not a credential, and clients must send it between the options call and the verify call. If you do not use passkeys, set Passkeys.Enabled to false. The session rule is in Antiforgery (CSRF) rules.

Options

AddAuthEndpoints<TUser, TContext>(…) and AddAuthEndpoints<TUser, TRole, TContext>(…) take AuthEndpointsOptions.

PropertyDefaultDescription
IdentityPath/identityRoute prefix for Identity management plus the configured sign-in stack
SignInCookieAuthEndpointsSignIn.Cookie or IdentityBearer. Pass IdentityBearer as the first argument to AddAuthEndpoints, or set o.SignIn.
PasskeyPath/accountRoute prefix for passkey endpoints
RequireConfirmedAccounttrueIdentity requires a confirmed account before sign-in
Passkeys(enabled)AuthEndpointsPasskeyOptions
EmailConfirmation(unset)ConfirmEmailRedirectUri and AllowedRedirectOrigins. The rules are in Configuration options.
Jwt(disabled)AuthEndpointsJwtOptions
EmailCode(disabled)AuthEndpointsEmailCodeOptions
ReAuth5 minutesAuthEndpointsReAuthOptions.Lifetime for the ReAuth cookie and reauthToken
ConfigureIdentitynullOptional Action<IdentityOptions> applied after secure defaults
ConfigurePasskeysnullOptional Action<IdentityPasskeyOptions> after ServerDomain is applied
RequireEmailSenderInProductiontrueProduction must register a real IEmailSender<TUser> (not Identity's no-op)

AuthEndpointsPasskeyOptions:

PropertyDefaultDescription
EnabledtrueWhen false, passkey DI and mapping are skipped
ServerDomainnullWebAuthn relying-party domain (e.g. example.com). Required in Production when enabled

AuthEndpointsJwtOptions:

PropertyDefaultDescription
EnabledfalseWhen true, registers and maps JWT endpoints
Path/authRoute prefix for JWT endpoints
ConfigurenullOptional Action<SimpleJwtOptions> for issuer, audience, signing, lifetimes

AuthEndpointsEmailCodeOptions (o.EmailCode):

PropertyDefaultDescription
EnabledfalseWhen true, registers and maps POST /emailCode/send and POST /emailCode/verify under IdentityPath
ConfigurenullOptional Action<EmailCodeOptions>. Set AllowSignUp here.

When Jwt.Enabled or EmailCode.Enabled is true, call modelBuilder.UseRefreshToken() or modelBuilder.UseEmailCodes() on your DbContext and migrate.

o.ReAuth.Lifetime is applied after every Configure<AuthEndpointsReAuthOptions>, so set the lifetime here on this facade.

builder.Services.AddAuthEndpoints<AppUser, AppDbContext>(o =>
{
    o.IdentityPath = "/auth/cookie";
    o.PasskeyPath = "/auth/passkey";
    o.RequireConfirmedAccount = true;
    o.Passkeys.ServerDomain = "example.com";
    o.ConfigureIdentity = identity =>
    {
        identity.Password.RequiredLength = 10;
    };
    o.ReAuth.Lifetime = TimeSpan.FromMinutes(2);
    o.Jwt.Enabled = true;
    o.Jwt.Path = "/auth/jwt";
    o.Jwt.Configure = jwt =>
    {
        jwt.Issuer = "https://example.com";
        jwt.Audience = "https://example.com";
        jwt.SigningOptions.SymmetricKey = builder.Configuration["Jwt:SymmetricKey"];
    };
});

AuthEndpointsOptionsValidator fails when the host also calls AddPasswordAuth. It checks the IdentityPath, PasskeyPath, and Jwt.Path formats, and the Production passkey domain. It checks EmailConfirmation with the same rules as AddPasswordAuth: an illegal redirect URI fails in every environment, and the https, allowlist, and origin checks run in Production. AuthEndpointsEmailSenderValidator checks the email sender in Production.

What it registers

AddAuthEndpoints calls AddAuthEndpointsIdentity and AddCookieAuthEndpoints. It also calls AddBearerAuthEndpoints when SignIn is IdentityBearer, AddPasskeyEndpoints unless Passkeys.Enabled is false, AddJwtEndpoints when Jwt.Enabled is true, and AddEmailCodeEndpoints when EmailCode.Enabled is true. Those calls register the ReAuth schemes and the rate-limit policies. AddAuthEndpointsIdentity sets Stores.SchemaVersion to version 3, which external unlink needs to count passkeys.

What it maps

GroupPrefixMapped when
Identity management: register, confirm and resend, forgot and reset, /manage/info, /manage/2fa, /manage/authMethods, /confirmIdentity, /confirmIdentity/passkeyOptionsIdentityPath (/identity)Always
Cookie POST /login, POST /logout, GET /csrfTokenIdentityPathSignIn is Cookie
Identity bearer POST /login, POST /refresh, POST /logoutIdentityPathSignIn is IdentityBearer
POST /emailCode/send, POST /emailCode/verifyIdentityPathEmailCode.Enabled is true
Passkey sign-in and management (MapPasskeyEndpoints)PasskeyPath (/account), under /passkeysPasskeys.Enabled is true
JWT POST /create, POST /refresh, GET /verify, POST /logout, GET /csrfTokenJwt.Path (/auth)Jwt.Enabled is true

It does not map POST /manage/password, DELETE /manage/password, or POST /confirmIdentity/emailCode/send. authMethods.emailCode stays false. It does not map external OAuth routes. Map them yourself, as on External OAuth.

The CSRF token routes are GET /identity/csrfToken for the cookie sign-in and GET /auth/csrfToken for JWT. The JWT route exists only with cookie refresh transport. With body transport, GET /auth/csrfToken returns 404.

How sign-in behaves

This facade ignores SignInCompletionOptions.Default. That covers password login, JWT POST /create, and email-code verify.

  • Cookie POST /identity/login uses the LoginCookie handler. ?useCookies=true has no effect there. A persistent cookie is ?useSessionCookies=false.
  • Login does not run the unknown-email hash verify, so an unknown email can return faster than a wrong password.
  • JWT POST /create keeps the 3.4.1 handler. A wrong authenticator code returns 401 with detail Invalid two factor code. and does not count toward lockout. A wrong recovery code returns 401 with the Identity error description (default English: "Recovery code redemption failed."). POST /create calls DefaultAuthenticator, so it does run the unknown-email hash verify.
  • Email-code verify uses an explicitly registered IEmailCodeSignInCompleter<TUser>, otherwise Identity bearer. Jwt.Enabled does not change it.
  • Passkey register and login use an explicitly registered IPasskeySignInCompleter<TUser>, otherwise Identity bearer. That completer follows the Identity bearer query flags (useCookies or useSessionCookies), not LoginCookie.