CodeLogic.TwoFactorAuth
4.5.2
dotnet add package CodeLogic.TwoFactorAuth --version 4.5.2
NuGet\Install-Package CodeLogic.TwoFactorAuth -Version 4.5.2
<PackageReference Include="CodeLogic.TwoFactorAuth" Version="4.5.2" />
<PackageVersion Include="CodeLogic.TwoFactorAuth" Version="4.5.2" />
<PackageReference Include="CodeLogic.TwoFactorAuth" />
paket add CodeLogic.TwoFactorAuth --version 4.5.2
#r "nuget: CodeLogic.TwoFactorAuth, 4.5.2"
#:package CodeLogic.TwoFactorAuth@4.5.2
#addin nuget:?package=CodeLogic.TwoFactorAuth&version=4.5.2
#tool nuget:?package=CodeLogic.TwoFactorAuth&version=4.5.2
CodeLogic.TwoFactorAuth
TOTP two-factor authentication with QR code generation for CodeLogic applications.
Install
dotnet add package CodeLogic.TwoFactorAuth
Quick Start
var tfaLib = new TwoFactorAuthLibrary();
// After library initialization via CodeLogic framework:
// Generate a new key for a user
var key = tfaLib.GenerateNewKey("MyApp", "user@example.com");
// Render a QR code for Google Authenticator / Authy
var qrDataUri = tfaLib.GenerateQrCodeDataUri(key);
// Use qrDataUri.Value in an <img src="..."> tag
// Validate a code entered by the user
var result = tfaLib.ValidateTotp("123456", key.Secret);
Console.WriteLine($"Valid: {result.IsValid}");
Features
- Secret key generation — cryptographically random Base32-encoded TOTP secrets
- TOTP validation — verify 6-digit codes with configurable time-step and drift window
- QR code rendering — PNG, BMP, Base64, and data URI output for authenticator app provisioning
- Google Authenticator compatible — standard
otpauth://URI format - Event integration — validation attempts are published to the CodeLogic event bus
Configuration
Config file: config.twofactorauth.json
{
"Enabled": true,
"TimeStepSeconds": 30,
"WindowSize": 1,
"QrCodeModuleSize": 20,
"ErrorCorrectionLevel": "Q"
}
Documentation
Full API docs: https://github.com/Media2A/CodeLogic.Libs
Requirements
- .NET 10.0+
- CodeLogic 3.x or 4.x
- Otp.NET 1.x
- QRCoder 1.x
License
MIT — see LICENSE
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.5.2 | 92 | 5/24/2026 |
| 4.5.1 | 105 | 5/24/2026 |
| 4.5.1-preview.56 | 83 | 5/24/2026 |
| 4.4.2-preview.53 | 45 | 5/24/2026 |
| 4.4.1 | 88 | 5/24/2026 |
| 4.0.5 | 95 | 5/15/2026 |
| 4.0.4 | 101 | 5/9/2026 |
| 4.0.3 | 99 | 5/9/2026 |
| 3.3.1 | 612 | 4/18/2026 |
| 3.3.0 | 103 | 4/18/2026 |
| 3.2.11 | 114 | 4/18/2026 |
| 3.2.10 | 100 | 4/18/2026 |
| 3.2.9 | 96 | 4/18/2026 |
| 3.2.8 | 97 | 4/18/2026 |
| 3.2.7 | 97 | 4/18/2026 |
| 3.2.6 | 95 | 4/18/2026 |
| 3.2.5 | 101 | 4/18/2026 |
| 3.2.4 | 104 | 4/17/2026 |
| 3.2.3 | 94 | 4/17/2026 |
| 3.2.2 | 151 | 4/17/2026 |
# CL.TwoFactorAuth — Changelog
All notable changes to **CodeLogic.TwoFactorAuth** are documented here. Versions follow
[Semantic Versioning](https://semver.org/).
## [4.5.0] — 2026-05-24
### Changed
- **Unified versioning.** All CodeLogic.Libs now share a single version line
controlled by `version.txt` in the repo root. This is a version alignment
release — no functional changes to this library.
## [4.0.4] — 2026-04-16
### Changed
- README + manifest refresh for the v4 baseline. No functional changes vs 4.0.3.
- `LibraryManifest.Version` now reads from assembly metadata.
## [4.0.2] — 2026-04-09
### Changed
- Annotated 2FA configuration with `[ConfigField]` for the admin UI surface.
- Aligned with the v4 baseline across all libraries.
## [4.0.0] — 2026-04-09
Major rewrite. Republished as v4.0.0 to reset the version line under the
unified v4 baseline. TOTP-based 2FA with QR code generation, backup codes,
and a CodeLogic-native flow for Google Authenticator / Authy / 1Password.
### Notes
- Earlier history is retained in the
[git log](https://github.com/Media2A/CodeLogic.Libs/commits/main/CL.TwoFactorAuth).