Authentication Examples
This page mirrors modules/authentication/examples/README.md in the experimental-modules repo (branch develop).
The repository is the source of truth.
Basic Example
The basic example demonstrates the authentication library with real HTTP requests using reqwest.
# Create .env file from template
cp .env.example .env
# Edit .env with your credentials
# Then run:
cargo run --example basic
TUI Example
A retro hacker-style Terminal User Interface (TUI) for interacting with the Auki authentication system.
Features
-
Left Panel: Configuration and credential inputs
- API URL, DDS URL, Client ID configuration
- Toggle between credential types (Email/Password, AppKey, Opaque)
-
Right Panel: Multiple tabs for different views
- Status Tab: Authentication pipeline status, token information with expiry countdowns
- Domains Tab: List of available domains with selection and multi-domain authentication
- Console Tab: Real-time authentication flow logs showing HTTP requests, responses, and events
- World Map Tab: ASCII world map showing all available domains and authenticated domains
-
Multi-Domain Support: Authenticate to multiple domains simultaneously to test the library's multi-domain token management
-
Retro Aesthetic: Dark green-on-black terminal style reminiscent of classic hacker terminals
Running the TUI
cargo run --example tui
Keyboard Controls
The TUI has two modes, similar to Vim:
Normal Mode (default)
- I: Enter input mode to edit fields
- TAB / SHIFT+TAB: Navigate between input fields
- C: Cycle through credential types (Email/Password → AppKey → Opaque)
- T: Toggle between tabs (Status → Domains → Console → World Map)
- F: Fetch available domains from Discovery service (requires discovery authentication)
- ↑ / ↓: Navigate domains list (in Domains tab)
- SPACE: Authenticate to selected domain (in Domains tab)
- ENTER: Start full authentication sequence (network → discovery → domain)
- Q / ESC: Quit application
Input Mode
- Type normally: Edit the focused field
- ENTER: Exit input mode (confirm input)
- ESC: Exit input mode (confirm input)
- BACKSPACE: Delete characters
Usage Flow
- Start the TUI:
cargo run --example tui - The app starts in Input Mode on the Email field
- Fill in configuration and credentials (see fields below)
- Press ESC to exit input mode, then press ENTER to start initial authentication (network + discovery)
- Watch the authentication progress in the Status tab
- Press T to navigate to the Domains tab
- Press F to fetch available domains (requires discovery token)
- Use ↑/↓ to navigate the domains list
- Press SPACE to authenticate to the selected domain
- Repeat steps 8-9 to authenticate to multiple domains
- Press T to view the World Map tab - see all domains plotted with authenticated ones highlighted in red
- View detailed logs in the Console tab
Configuration Fields
Fill in all required fields:
- API URL (default: https://api.aukiverse.com)
- DDS URL (default: https://dds.posemesh.org)
- Client ID (default: rust-tui)
- Refresh Threshold in milliseconds (default: 300000)
- Credentials based on selected type:
- Email/Password: Email and password
- AppKey: App key and app secret
- Opaque: Opaque token and expiry timestamp
Features in Action
The TUI demonstrates the full authentication flow:
- Network authentication: Authenticate with the Auki API (press ENTER)
- Discovery service authentication: Get discovery token (automatic with network auth)
- Fetch available domains: Query DDS API for domains you have access to (press F in Domains tab)
- Multi-domain authentication: Authenticate to multiple domains simultaneously (press SPACE on selected domains)
All requests, responses, and events are logged in real-time with color coding:
- Green: Success messages and authenticated items
- Red: Errors and failures
- Yellow: Warnings and available (not authenticated) items
- Cyan: System messages and selected items
The World Map tab shows:
- Yellow dots: Available domains (not authenticated)
- Red dots with labels: Authenticated domains with domain name