Concepts
Prepare for production
Checklist for deploying AuthEndpoints: HTTPS, core settings, email codes, JWT, GitHub and Google OAuth, browser setup, and startup validation.
Work through this checklist before you deploy. Startup validation catches some items. The rest are your responsibility.
Check the core settings
- Serve the API over HTTPS.
- Register a real
IEmailSender<TUser>. WhenRequireEmailSenderInProductionistrue(the default), startup fails in Production while Identity's no-op sender is registered. - On the password facade, set
Passkeys.ServerDomainonly when you want passkeys. Leave it unset to keep them off. A whitespace value fails startup in Production. - On the 3.x facade, passkeys are on until
Passkeys.Enabledisfalse. Production then requiresPasskeys.ServerDomain. - Leave
RequireConfirmedAccountattrueunless you have another way to verify email ownership.
Check the email-code settings
Skip this section if email-code sign-in is off.
- Call
modelBuilder.UseEmailCodes()and apply the migration.MapEmailCodeEndpointsthrows without that entity. The table isAuthEndpoints.AuthEndpointsEmailCodes. - Register a real
IEmailCodeSender<TUser>.IEmailSender<TUser>does not send the code. Outside Development, startup fails whileDevelopmentEmailCodeSender<TUser>or no sender is registered, unlessRequireSenderOutsideDevelopmentisfalse. - Queue the message and return. Send awaits
SendSignInCodeAsync.CodeandLinkUrlare raw. Encode them in an HTML template, and do not log them. - If the magic link is on, set
LinkUrito an absolutehttpsURI with no#, and list that origin inMagicLink.AllowedOrigins. - Leave
AllowSignUpoff unless an unknown address should become a confirmed user with no password.
Check the JWT settings
Skip this section if JWT is off.
- Call
modelBuilder.UseRefreshToken()on yourDbContextand apply the migration. - Set an issuer and an audience. Startup fails in Production with the library defaults (
JwtandJwtAudience). - Use a symmetric key of at least 256 bits (32 UTF-8 bytes), or an asymmetric key.
- If you upgrade from plaintext refresh-token storage, recreate the
AuthEndpointsRefreshTokenstable. AuthEndpoints now stores hashed tokens with reuse detection.
Check the external OAuth settings
Skip this section if you do not use GitHub or Google.
- Map the OAuth routes yourself.
MapAuthEndpointsdoes not map them. - Host a page at
ErrorPath(default/auth/external/error). - Leave
AutoLinkByEmailoff unless a verified provider email should attach to an existing confirmed account. - Keep
RequireVerifiedEmailon.
Check the browser setup
- If the client runs on another origin, add a CORS policy with credentials. See Call the API from a browser.
- Decide whether passkey and OAuth sign-in skipping 2FA fits your threat model. See Security model.
What the validators check
AuthEndpointsOptionsValidatorchecksIdentityPath,PasskeyPath, andJwt.Pathformats, and the Production passkey domain.AuthEndpointsEmailSenderValidatorchecks the email sender in Production.EmailCodeSenderValidator<TUser>checksIEmailCodeSender<TUser>outside Development when email-code sign-in is registered andRequireSenderOutsideDevelopmentistrue.EmailCodeOptionsValidatorchecks code length, lifetime, attempts, cooldown, send caps, and the magic-link URI.- JWT options validation rejects the default issuer and audience in Production, and checks the key material against the signing algorithm.
AddGitHubandAddGooglereject an emptyClientIdorClientSecretat startup.
Related
Security model
How AuthEndpoints hides which accounts exist, finishes each sign-in in a session, protects account changes, and which trade-offs it leaves to the host.
FAQ
Does AuthEndpoints replace Identity? Cookies, JWT, or opaque bearer tokens? Logout, chosen routes, and passkeys compared with MapIdentityApi.