Offline Authentication

Overview

Offline authentication provides a network-free authentication mode suitable for:

  • Testing and Development - No external dependencies

  • Offline Play - Single-player or LAN games

  • Cracked Launchers - Non-premium Minecraft clients (use responsibly)

Features

  • No Network Required - Works without internet connection

  • Deterministic UUIDs - Same username always generates the same UUID

  • Fast - Authentication completes in microseconds

  • Username Validation - Enforces Minecraft username rules

Quick Start

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

#[tokio::main]
async fn main()  {
    let mut auth = OfflineAuth::new("Steve");
    let profile = auth.authenticate().await?;

    println!("Username: {}", profile.username);
    println!("UUID: {}", profile.uuid);
    println!("Access Token: {:?}", profile.access_token); // None

    Ok(())
}

Username Validation Rules

The offline authenticator enforces Minecraft username requirements:

Length Requirements

  • Minimum: 3 characters

  • Maximum: 16 characters

Character Requirements

  • Allowed: Letters (a-z, A-Z), numbers (0-9), underscore (_)

  • Not Allowed: Spaces, special characters, emojis

UUID Generation

Algorithm

Offline UUIDs are generated using UUID v5 (SHA1-based):

Properties

  • Deterministic: Same username → same UUID

  • Standard Compliant: Follows RFC 4122 UUID v5 specification

  • Unique: Different usernames produce different UUIDs

  • Compatible: Works with Minecraft protocol

Examples

UserProfile Output

The UserProfile returned by offline authentication:

Event System Integration

With the events feature enabled:

Events Emitted:

  1. AuthenticationStarted { provider: "Offline" }

  2. AuthenticationSuccess { provider: "Offline", username: "Steve", uuid: "..." }

Or on error:

  1. AuthenticationStarted { provider: "Offline" }

  2. AuthenticationFailed { provider: "Offline", error: "Username must be between 3 and 16 characters" }

Error Handling

Use Cases

1. Development and Testing

2. LAN Multiplayer

3. Fallback Authentication

Limitations

No Token Management

  • No verify() support: Cannot verify sessions

  • No logout() support: No sessions to invalidate

  • No access token: access_token is always None

Not Suitable for Online Servers

  • No server-side validation

  • No skin/cape support

  • No account ownership verification

  • May be blocked by server anti-cheat

Performance

Offline authentication is extremely fast:

Breakdown:

  • Username validation: ~1µs

  • SHA1 hashing: ~20µs

  • UUID formatting: ~10µs

  • Profile creation: ~20µs

  • Total: ~50µs

Best Practices

Username Input Validation

UUID Caching

Testing

Last updated