Skip to content

AuthVaultix/AuthVaultix-Rust-Example-main

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AuthVaultix Logo

AuthVaultix Rust Example

A complete, ready-to-use Rust CLI integration example for the AuthVaultix authentication platform.

Rust AuthVaultix License Discord Platform


πŸ“– Overview

This repository provides a plug-and-play Rust CLI example demonstrating how to integrate the AuthVaultix authentication API into your Rust application. It includes:

  • πŸ” Login β€” Authenticate users with username & password
  • πŸ“ Register β€” Create new accounts with a license key
  • πŸ”‘ License Login β€” Access the app using only a license key
  • πŸ–₯️ HWID Detection β€” Automatically reads the Windows User SID as hardware fingerprint
  • πŸ“Š User Info Display β€” Shows username, IP, HWID, creation date, last login & active subscriptions
  • ⏱️ Expiry Countdown β€” Human-readable time-left format (Xd Xh Xm)

Built as a terminal-based interactive menu app β€” fully blocking/synchronous using reqwest blocking client.


πŸ—‚οΈ Project Structure

authvaultix-rust-example/
β”œβ”€β”€ Cargo.toml          # Dependencies & package metadata
β”œβ”€β”€ run.bat             # Quick run script for Windows
└── src/
    β”œβ”€β”€ main.rs         # Entry point β€” interactive CLI menu
    └── lib.rs          # AuthVaultix API wrapper (core library)

⚑ Quick Start

1. Prerequisites

  • Rust (latest stable, 2024 edition)
  • Windows OS (HWID detection uses PowerShell / WMIC)
  • An AuthVaultix account β†’ Register here

2. Clone the Repository

git clone https://github.com/AuthVaultix-Rust-Example-main.git
cd AuthVaultix-Rust-Example-main

3. Configure Your Credentials

Open src/main.rs and fill in your application details from the AuthVaultix Dashboard:

let mut AuthVaultixApp = AuthVaultix::new(
    "YourAppName",   // name
    "your_ownerid",  // ownerid
    "your_secret",   // secret
    "1.0"            // version
);

⚠️ Never commit real credentials to a public repository.

4. Build & Run

cargo run

Or use the included Windows batch script:

run.bat

πŸ–₯️ CLI Usage

When you run the app, you'll see an interactive menu:

Connecting...
βœ… Initialized Successfully!

[1] Login
[2] Register
[3] License Login
[4] Exit
Choose option:

Login (Option 1)

Username: johndoe
Password: β€’β€’β€’β€’β€’β€’β€’β€’

βœ… Logged in!

=== User Data ===
Username: johndoe
IP: 192.168.x.x
HWID: S-1-5-21-...
Created: 2025-01-01 08:00:00 AM
Last Login: 2026-05-04 05:00:00 PM

Subscriptions:
[1] default | Expiry: 2027-01-01 12:00:00 AM | Timeleft: 240d 6h 0m

Register (Option 2)

Username: newuser
Password: β€’β€’β€’β€’β€’β€’β€’β€’
License: XXXX-XXXX-XXXX-XXXX

βœ… Registered Successfully!

License Login (Option 3)

License: XXXX-XXXX-XXXX-XXXX

βœ… License Login Successful!

🧩 Library Usage (lib.rs)

You can use the AuthVaultix struct directly in your own Rust project:

Initialize

use AuthVaultix_rust::AuthVaultix;

let mut app = AuthVaultix::new("AppName", "ownerid", "secret", "1.0");
app.init(); // Must be called before any other method

Login

app.login("username", "password");

Register

app.register("username", "password", "LICENSE-KEY");

License Login

app.license_login("LICENSE-KEY");

βš™οΈ API Reference

Authentication & Session

Method Returns Description
init() () Initializes the session with the API.
login(username, pass) () Authenticates a user.
register(username, pass, license, email) () Registers a new user.
license_login(license) () Authenticates directly via license key.
check() bool Validates the current session.
logout() () Terminates session.

Account Management

Method Returns Description
upgrade(username, license) bool Upgrades user's subscription.
forgot_password(username, email) bool Triggers a password reset email.
change_username(new_username) () Changes the current user's username.

Security & Logging

Method Returns Description
ban(reason) bool Bans the currently authenticated user.
check_blacklist() bool Checks if the current HWID is blacklisted.
log(message) bool Sends a log message to the dashboard.

Variables & Data

Method Returns Description
get_global_var(varid) Option<String> Fetches a global server variable.
get_var(var_name) Option<String> Fetches a user-specific variable.
set_var(var_name, value) bool Sets a user-specific variable.
download(fileid) Option<Vec<u8>> Securely downloads a file into a byte vector.

Communication

Method Returns Description
fetch_online() Option<Vec<OnlineUser>> Retrieves a list of online clients.
chat_send(message, channel) bool Sends a chat message.
chat_fetch(channel) Option<Vec<ChatMessage>> Fetches chat history for a channel.

πŸ“¦ Dependencies

Crate Version Purpose
reqwest 0.11 HTTP client (blocking + JSON)
serde 1.0 Serialization / Deserialization
serde_json 1.0 JSON parsing
chrono 0.4 Unix timestamp β†’ human-readable date

Cargo.toml:

[dependencies]
chrono = "0.4"
reqwest = { version = "0.11", features = ["blocking", "json"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

πŸ–₯️ HWID Detection

This example uses your Windows User SID as a hardware fingerprint. It tries two methods in order:

  1. PowerShell (primary):

    [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value
  2. WMIC (fallback):

    wmic useraccount where name='%USERNAME%' get sid /value

If both fail, it falls back to "UNKNOWN_HWID".


πŸ”’ Security Notes

Concern Recommendation
Credentials in main.rs Use environment variables or a config file in production
HWID Binding AuthVaultix locks sessions to the detected SID by default
HTTPS All API calls go to https://authvaultix.com β€” always encrypted
Error Handling Production apps should handle panics gracefully with Result<> returns

πŸ› οΈ Customization

  • Add 2FA support: Extend the login() and license_login() payloads with a "code" field
  • Subscription gating: Check info.subscriptions for a specific tier name before granting access
  • Cross-platform HWID: Replace the PowerShell SID logic with a cross-platform crate like machine-uid for Linux/macOS support
  • GUI: Integrate with egui or tauri to build a desktop GUI on top of this library

🀝 Contributing

Contributions, issues, and feature requests are welcome!

  1. Fork the repository
  2. Create a new branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -m 'Add my feature'
  4. Push to the branch: git push origin feature/my-feature
  5. Open a Pull Request

πŸ’¬ Support


πŸ“„ License

This project is licensed under the MIT License β€” feel free to use, modify, and distribute it.


Made with πŸ¦€ Rust + ❀️ using AuthVaultix