Skip to content

v1.0.0

Choose a tag to compare

@dgates82 dgates82 released this 22 Aug 17:15
· 42 commits to main since this release
100d4b5

DGates.Identity.Jwt2Fa v1.0.0

Real, claims-bearing JWTs and multi-channel two-factor authentication (Authenticator/TOTP, Email, SMS) for ASP.NET Core Identity — generic over your own TUser.

Extracted from angular-dotnet-auth-template, where this logic previously lived directly in the template's controllers. This release generalizes it into a standalone package: two opt-in modules (AddAuthCore/MapAuthCore and Add2Fa/Map2Fa), four small capability interfaces so TUser only needs to implement what it uses, and a full admin user-management surface alongside auth — extracted together because both concerns shared the same TUser genericization problem in the source app.

Why this instead of MapIdentityApi<TUser>?

ASP.NET Core's built-in Identity API endpoints cover TOTP + recovery codes only (no SMS/email 2FA) and issue opaque, encrypted bearer tokens rather than real JWTs. This package fills both gaps for teams that want their own first-party JWT auth without adopting a full OAuth2/OIDC provider like Duende IdentityServer.

Highlights

  • Two opt-in modules, four capability interfaces — skip what you don't use, compile-error (not silent no-op) if you use one without its interface
  • Full admin user-management (list/get/create/update/unlock, activate/deactivate) gated by a Jwt2FaPolicies.AdminOnly policy built on JWT role claims — also usable directly on your own app's endpoints
  • Business logic lives in injectable services (Jwt2FaResult<T>), not endpoint delegates — every service is testable and usable outside this package's own minimal-API layer
  • Every email/SMS this package sends has an overridable subject/body — no fork required for different copy
  • Baseline safety net on every mapped endpoint: unhandled exceptions become a generic 500, invalid requests get a 400 ValidationProblem, with no setup required

Hardening

This release went through real integration testing against angular-dotnet-auth-template before publishing — several issues were found and fixed in the process, including a regressed authorization check on 2FA method switching (previously fixed once in the source app, dropped again during the port) and gaps in exception/validation handling that came from moving off MVC controllers. Full detail in CHANGELOG.md.

Requires

.NET 10. Bring your own IEmailSender/ISmsSender, or use DGates.Identity.NotificationProviders for both.