#authenticate #cloud #client #stupid #2fa #env #key

stupid-2fa

A simple way to authenticate client app without cloud

1 unstable release

0.1.0 Jul 19, 2024

#327 in Authentication

Download history 110/week @ 2024-07-14 13/week @ 2024-07-21 1/week @ 2024-07-28

70 downloads per month

MIT license

7KB
121 lines

Stupid 2FA

A simple way to authenticate client app without cloud

use

This project use the env variable STUPID_2FA_PRIVATE_KEY as the private key

An simple example of it working

fn main() {
    let lock_code = generate_lock_code();
    println!("Lock Code: {}", lock_code);

    let subscription_days = 30;
    let unlock_code = generate_unlock_code(&lock_code, subscription_days);
    println!("Unlock Code: {}", unlock_code);

    let is_valid = validate_unlock_code(&lock_code, &unlock_code, subscription_days);
    println!("Is Unlock Code Valid? {}", is_valid);
}

Functionalities

  • HMAC-based auth

Reference

some articles on the topic of authentication

License

MIT

contributing

Contributions are always welcome! any suggestions, open a pull request or a issue.

code of conduct: format your code, thx.

Dependencies

~3MB
~50K SLoC