Skip to content

AuthVaultix/AuthVaultix-Go-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AuthVaultix Logo

AuthVaultix Go Example

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

Go AuthVaultix License Discord Platform


πŸ“– Overview

This repository provides a plug-and-play Go CLI example demonstrating how to integrate the AuthVaultix authentication API into your Go 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 via PowerShell
  • πŸ“Š User Info Display β€” Shows username, IP, HWID & active subscriptions with expiry
  • 🌐 HTTPS API v1.0 β€” Communicates with https://authvaultix.com/api/1.0/

Built as a terminal-based interactive CLI app using only Go's standard library (no external HTTP dependencies needed beyond encoding/json and net/http).


πŸ—‚οΈ Project Structure

authvaultix-go-example/
β”œβ”€β”€ main.go             # Entry point β€” interactive CLI menu
β”œβ”€β”€ authvaultix.go      # AuthVaultix API wrapper (core library)
└── run.bat             # Quick setup & run script for Windows

⚑ Quick Start

1. Prerequisites

  • Go 1.21 or higher
  • Windows OS (HWID detection uses PowerShell)
  • An AuthVaultix account β†’ Register here

2. Clone the Repository

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

3. Configure Your Credentials

Open main.go and fill in your application details from the AuthVaultix Dashboard:

AuthVaultixApp := NewAuthVaultix(
    "YourAppName",   // name
    "your_ownerid",  // ownerid
    "your_secret",   // secret
    "1.0",           // version
)

⚠️ Never commit real credentials to a public repository.

4. Initialize Go Module & Run

go mod init authvaultix
go run .

Or simply 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 Info:
  Username: johndoe
  IP: 192.168.x.x
  HWID: S-1-5-21-...
  β†’ default | Expiry: 1767225600 | Left: 20736000

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 (authvaultix.go)

You can use the Authvaultix struct directly in your own Go project:

Initialize

app := NewAuthVaultix("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.LicenseLogin("LICENSE-KEY")

βš™οΈ API Reference

Authentication & Session

Method Returns Description
Init() bool Initializes the session with the API.
Login(username, pass) bool Authenticates a user.
Register(user, pass, key, email) bool Registers a new user.
LicenseLogin(licenseKey) bool Authenticates directly via license key.
Check() bool Validates the current session.
Logout() Terminates session.

Account Management

Method Returns Description
Upgrade(username, licenseKey) bool Upgrades user's subscription.
ForgotPassword(username, email) bool Triggers a password reset email.
ChangeUsername(newUsername) Changes the current user's username.

Security & Logging

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

Variables & Data

Method Returns Description
GetGlobalVar(varId) string Fetches a global server variable.
GetVar(varName) string Fetches a user-specific variable.
SetVar(varName, value) bool Sets a user-specific variable.
Download(fileId) []byte Securely downloads a file.

Communication

Method Returns Description
FetchOnline() []OnlineUser Retrieves a list of online clients.
ChatSend(message, channel) bool Sends a chat message.
ChatFetch(channel) []ChatMessage Fetches chat history for a channel.

πŸ“¦ Dependencies

This project uses only the Go standard library β€” no go get required for the core SDK.

Package Source Purpose
net/http stdlib HTTP POST requests to the API
encoding/json stdlib JSON parsing of API responses
os/exec stdlib PowerShell HWID detection
bytes, strings, fmt, io stdlib Utilities

The run.bat calls go mod init authvaultix automatically β€” no manual module setup needed.


πŸ–₯️ HWID Detection

This example uses your Windows User SID (Security Identifier) as the hardware fingerprint, fetched via PowerShell:

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

If the command fails for any reason, it falls back to "UNKNOWN_HWID".

For cross-platform support, you can replace this with a library like github.com/denisbrodbeck/machineid.


πŸ”’ Security Notes

Concern Recommendation
Credentials in main.go Use environment variables (os.Getenv) 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
URL Encoding Use url.Values instead of manual string building for production safety

πŸ› οΈ Customization

  • Add 2FA support: Extend the Login() and License() payload maps with a "code" key
  • Subscription gating: Loop through user.Subscriptions and check for a specific sub.Subscription name before granting app access
  • Cross-platform HWID: Replace PowerShell logic with machineid for Linux/macOS support
  • GUI: Build a desktop frontend using Fyne or Wails on top of this core 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 🐹 Go + ❀️ using AuthVaultix

About

the official example showcased on AuthVaultix's Organization GitHub page!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages