Themia.SecondFactor 0.63.1

dotnet add package Themia.SecondFactor --version 0.63.1
                    
NuGet\Install-Package Themia.SecondFactor -Version 0.63.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Themia.SecondFactor" Version="0.63.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Themia.SecondFactor" Version="0.63.1" />
                    
Directory.Packages.props
<PackageReference Include="Themia.SecondFactor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Themia.SecondFactor --version 0.63.1
                    
#r "nuget: Themia.SecondFactor, 0.63.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Themia.SecondFactor@0.63.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Themia.SecondFactor&version=0.63.1
                    
Install as a Cake Addin
#tool nuget:?package=Themia.SecondFactor&version=0.63.1
                    
Install as a Cake Tool

Themia.SecondFactor

Multi-method second factor for an app's sign-in: passkey, TOTP, recovery codes, email OTP and SMS OTP, with a per-app and per-role policy (MfaPolicyOptions), method strength (passkey, TOTP and recovery codes are strong; email and SMS are weak and never claim mfa alone), an admin reset with a role-level act-on rule, and a break-glass reset kept in the database. Storage is yours to choose through IMfaMethodStore; Themia.SecondFactor.PostgreSql is the shipped store. Wire it with AddThemiaSecondFactor(...) and give it an ISecondFactorSecretProtector (Data Protection or a KMS) and an ISecondFactorContactResolver.

Importing existing TOTP secrets (no re-enrol)

An app that already holds TOTP secrets can move its users over without making them scan a new QR code. Copy each secret into the store once, under the protection scheme it has today, and let the protector read that scheme:

  1. Implement ISecondFactorSecretProtector so Unprotect(scheme, protectedSecret) handles every scheme still in the data: the old one and the one Protect writes now (Scheme). Return null for a scheme it does not know; verification then fails closed (SecondFactorOutcome.NotAvailable) instead of guessing.
  2. Add one method per user with IMfaMethodStore.AddAsync(new NewMfaMethod { ... }): Kind = MfaMethodKind.Totp, SecretProtected = the stored value as it is (do not decrypt and re-encrypt), ProtectionScheme = the scheme that protects it, Label, EnrolledAt.
  3. Carry the replay position: set LastUsedStep to the last accepted time step (Unix seconds / 30) if the old system recorded one; leave it at -1 only when it did not. A code of that step or earlier is then refused as Replayed.
  4. Keep the old scheme readable for as long as any imported row uses it; the scheme is stored per row, so old and new coexist.

Limits to check before running the import:

  • Secret length: Themia.Totp rejects a secret that decodes to fewer than 16 bytes (RFC 4226 §4, 128 bits) by throwing when it is used. Older systems often issued 80-bit secrets (16 base32 characters); those cannot be imported as they are, and those users must re-enrol. The import does not check the length: a short secret is stored, then throws at sign-in (not a clean refusal). Screen every secret's decoded length before importing and leave the short ones to re-enrol.
  • Digits, period and algorithm: one TotpOptions applies to every user (defaults: 6 digits, 30-second step, SHA-1, what authenticator apps use). Set them to match the old system before importing; secrets issued with different parameters cannot be mixed.
  • The method id is new. The replay record is keyed on the new method id, so import before the first sign-in, not during it.

tests/Themia.SecondFactor.IntegrationTests/LegacyTotpImportTests.cs runs this recipe against Postgres: a legacy-scheme secret verifies, the imported LastUsedStep blocks a replay, and an unreadable scheme fails closed.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Themia.SecondFactor:

Package Downloads
Themia.Modules.Identity.ExternalAuth.AspNetCore

External OAuth/OIDC authentication for Themia Identity — server-side code→token exchange, PKCE, token-bound nonce, id-token validation, JWKS RS256 + HS256, and the external-login flow over a bring-your-own IExternalLoginService. No EF/Dapper, no user store.

Themia.SecondFactor.PostgreSql

PostgreSQL (15+) Dapper store + FluentMigrator runner for Themia.SecondFactor.

Themia.Modules.Identity.SecondFactor

Bridge between Themia.SecondFactor and Themia Identity — the second-factor policy over the multi-method service, verify-then-complete for pending logins, per-session proof reads and the restriction lift after a strong enrolment.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.63.1 49 11/14/2026
0.63.0 45 11/14/2026
0.62.1 51 11/14/2026
0.62.0 62 11/14/2026
0.61.1 63 11/14/2026
0.61.0 56 11/13/2026
0.60.0 93 11/10/2026
0.59.0 85 11/10/2026
0.58.0 95 11/9/2026
0.57.2 94 11/8/2026