How to Use lighty-auth

Basic Usage

Offline Authentication

For local development and testing without network access:

use lighty_auth::{offline::OfflineAuth, Authenticator};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Create offline authenticator
    let mut auth = OfflineAuth::new("Player123");

    // Authenticate (without events)
    #[cfg(not(feature = "events"))]
    let profile = auth.authenticate().await?;

    // Authenticate (with events)
    #[cfg(feature = "events")]
    let profile = auth.authenticate(None).await?;

    println!("Username: {}", profile.username);
    println!("UUID: {}", profile.uuid); // Deterministic UUID

    Ok(())
}

Key features:

  • No network required

  • Deterministic UUID generation (same username = same UUID)

  • Perfect for development and testing

Microsoft Authentication

OAuth 2.0 Device Code Flow for legitimate Minecraft accounts:

Key features:

  • Device code flow (no embedded browser needed)

  • Full Xbox Live and Minecraft Services integration

  • Returns Minecraft access token for session validation

Azuriom Authentication

Server-based authentication with custom CMS:

Key features:

  • Two-factor authentication support

  • User roles with colors

  • Money/credits tracking

  • Email verification status

With Events

Track authentication progress with events:

Custom Authenticator

Implement the Authenticator trait for your own authentication system:

Offline UUID Generation

Generate deterministic UUIDs for offline mode:

How it works:

  • Uses SHA1 hash of username

  • Formats as Minecraft-compatible UUID with dashes

  • Deterministic: same input always produces same output

Error Handling

Feature Flags

Available features:

  • events - Enables AuthEvent emission (requires lighty-event)

  • tracing - Enables logging macros

Exports

In lighty_auth:

In lighty_launcher:

  • Overview - Architecture and design

  • Events - AuthEvent types

  • Exports - Complete export reference

  • Offline - Offline authentication details

  • Microsoft - Microsoft OAuth flow details

  • Azuriom - Azuriom authentication details

  • Trait - Implementing custom authenticators

Last updated