ezauth.lib
0.1.0
dotnet add package ezauth.lib --version 0.1.0
NuGet\Install-Package ezauth.lib -Version 0.1.0
<PackageReference Include="ezauth.lib" Version="0.1.0" />
paket add ezauth.lib --version 0.1.0
#r "nuget: ezauth.lib, 0.1.0"
// Install ezauth.lib as a Cake Addin #addin nuget:?package=ezauth.lib&version=0.1.0 // Install ezauth.lib as a Cake Tool #tool nuget:?package=ezauth.lib&version=0.1.0
ezauth
Dead simple user authentication for C# with support for 2FA.
Usage
Add reference to ezauth.lib project.
TOTP Example
TOTP - Time-based One-Time Password is an algorithm that generates a one-time password based on a secret key and the current time.
Defined in IETF RFC 6238, TOTP is usually used as a second factor in a 2FA setup.
Users will need to have a TOTP client like Google Authenticator.
Code Example
using ezauth.lib.AuthProviders; // init new totp provider TOTPProvider totp = new TOTPProvider("ezauth_totp_test"); // get the otp uri for sharing the secret with // a client e.g. Google Authenticator // Usually you'll encode this into a QR code (try QRCoder) string URI = totp.GetOTPURI(); // validate the code given by the user for authentication AuthorizationData res = totp.Validate(user.username, input); // get the result of the Validate operation if (res.Result == AuthResult.VALIDATED) { Console.WriteLine("Your code was valid!"); string token = res.AuthToken; // your JWT token for login later } else if (res.Result == AuthResult.INVALID_PASSCODE) { Console.WriteLine("Invalid code."); }
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
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 |
---|---|---|
0.1.0 | 1,251 | 1/20/2018 |
Initial release. TOTP authentication only for now.