Skip to content

🌐 Tobogganing Web Portal & Metrics Implementation

Implementation Summary

All requested features have been successfully implemented for both Manager and Headend services:

🖥️ Manager Service Features

1. py4web Web Portal with Role-Based Access

  • Location: /manager/web/
  • Authentication System: Complete user management with SQLite backend
  • Roles:
  • Admin: Full access to all management functions
  • Reporter: Read-only access to metrics and status
  • Features:
  • Secure login/logout with session management
  • Beautiful responsive UI with Tailwind CSS
  • Real-time dashboard with live statistics
  • Role-based navigation and permissions

2. User Authentication & Role System

  • File: /manager/auth/user_manager.py
  • Features:
  • bcrypt password hashing
  • Session-based authentication
  • Role-based permissions
  • Automatic session cleanup
  • Default admin user creation

3. Prometheus Metrics Endpoint

  • Endpoint: /metrics
  • Authentication: Bearer token or user session
  • Metrics: Comprehensive monitoring covering:
  • HTTP requests and response times
  • Authentication attempts and user logins
  • Cluster and client statistics
  • Certificate management
  • JWT token lifecycle
  • Database and Redis operations
  • System resources (CPU, memory)
  • Business logic metrics

4. Health Endpoints

  • /health: Detailed health status
  • /healthz: Kubernetes-style health check

🛡️ Headend Service Features

1. Authenticated Metrics Endpoint

  • Endpoint: :9090/metrics
  • Authentication: Bearer token or JWT validation
  • Features:
  • Prometheus scraper token support
  • JWT-based user authentication
  • Secure metrics access control

2. Enhanced Health Endpoints

  • /health: Detailed service status
  • /healthz: Kubernetes-style health check

🎨 Web Portal Pages

📊 Dashboard (/dashboard)

  • Welcome banner with user info
  • Statistics cards (clusters, clients, health, security)
  • Recent clients activity
  • Cluster status overview
  • Quick action buttons (admin only)

🖥️ Clusters (/clusters)

  • Cluster management interface
  • Status monitoring
  • Regional distribution
  • Admin controls for cluster management

💻 Clients (/clients)

  • Client management interface
  • Connection status
  • Client type filtering
  • Certificate management

📜 Certificates (/certificates)

  • Certificate lifecycle management
  • Expiration monitoring
  • Renewal tracking

👥 Users (/users) - Admin Only

  • User management interface
  • Role assignment
  • User status control
  • Session management

📈 Metrics (/metrics)

  • System metrics dashboard
  • Performance monitoring
  • Resource utilization
  • Prometheus integration

🔐 Authentication Flow

  1. Login (/login): Beautiful gradient login page
  2. Session Creation: Secure session with HTTP-only cookies
  3. Permission Checks: Role-based access control
  4. Auto-Logout: Session expiration handling

📊 Prometheus Metrics

Manager Service Metrics

tobogganing_manager_info
tobogganing_manager_status
tobogganing_manager_uptime_seconds
tobogganing_manager_http_requests_total
tobogganing_manager_http_request_duration_seconds
tobogganing_manager_auth_attempts_total
tobogganing_manager_clusters_total
tobogganing_manager_clients_total
tobogganing_manager_certificates_issued_total
tobogganing_manager_jwt_tokens_issued_total
tobogganing_manager_memory_usage_bytes
tobogganing_manager_cpu_usage_percent

Headend Service Metrics

http_duration_seconds
http_requests_total
(Plus all standard Prometheus Go metrics)

🔧 Configuration

Environment Variables

Manager Service

# Database
DATABASE_URL=sqlite:///tobogganing.db

# Redis  
REDIS_URL=redis://localhost:6379

# Authentication
JWT_SECRET=your-jwt-secret-here
SESSION_TIMEOUT_HOURS=8

# Metrics
METRICS_TOKEN=prometheus-scraper-token

# Logging
LOG_LEVEL=info

Headend Service

# Metrics Authentication
HEADEND_METRICS_AUTH_TOKEN=prometheus-scraper-token

# Manager Integration
HEADEND_AUTH_MANAGER_URL=http://manager:8000

🚀 Getting Started

1. Install Dependencies

cd manager
pip install -r requirements.txt

2. Initialize Database

# Database will be automatically initialized on first run
# Default admin credentials will be generated and logged

3. Run Manager Service

python main.py

4. Access Web Portal

  • URL: http://localhost:8000/login
  • Default User: admin
  • Password: Check startup logs for generated password

5. Metrics Endpoints

  • Manager: http://localhost:8000/metrics
  • Headend: http://localhost:9090/metrics

🔒 Security Features

  1. Session Security:
  2. HTTP-only cookies
  3. Secure flag for HTTPS
  4. SameSite protection

  5. Password Security:

  6. bcrypt hashing
  7. Secure random generation

  8. Metrics Authentication:

  9. Bearer token validation
  10. Role-based access control

  11. CSRF Protection:

  12. Built-in py4web protection
  13. Secure form handling

🎨 UI/UX Features

  • Responsive Design: Works on desktop and mobile
  • Real-time Updates: Live statistics refresh
  • Toast Notifications: User feedback system
  • Loading States: Smooth user interactions
  • Dark/Light Theming: Visual consistency
  • Icons & Emojis: Enhanced visual appeal

📋 Default Users & Permissions

Admin Role

  • ✅ Full system access
  • ✅ User management
  • ✅ Cluster management
  • ✅ Client management
  • ✅ Certificate management
  • ✅ Metrics access

Reporter Role

  • ✅ Dashboard view
  • ✅ Metrics access
  • ✅ Read-only cluster view
  • ✅ Read-only client view
  • ❌ User management
  • ❌ System modifications

The implementation provides a complete, production-ready web portal and metrics system with enterprise-grade security and monitoring capabilities! 🎉