ezauth.lib 0.1.0

Dead simple user authentication for C# with support for 2FA.

Install-Package ezauth.lib -Version 0.1.0
dotnet add package ezauth.lib --version 0.1.0
<PackageReference Include="ezauth.lib" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ezauth.lib --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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.");
    }
    

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.");
    }
    

Release Notes

Initial release. TOTP authentication only for now.

Dependencies

This package has no dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.1.0 317 1/20/2018