152 lines
5.3 KiB
Python
152 lines
5.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Instructions for accessing Web UI with correct authentication
|
|
"""
|
|
|
|
import requests
|
|
import base64
|
|
import webbrowser
|
|
|
|
# Configuration
|
|
WEBUI_URL = "http://localhost:3015/webui/"
|
|
USERNAME = "jleu3482"
|
|
PASSWORD = "jleu1212"
|
|
|
|
def demonstrate_webui_access():
|
|
"""Show how to access Web UI with authentication"""
|
|
print("=== WEB UI ACCESS INSTRUCTIONS ===")
|
|
print("\nYour Web UI login is WORKING, but it uses Basic Authentication (not a form).")
|
|
print("\nHere's how to access it:")
|
|
|
|
# Method 1: Direct URL with credentials
|
|
auth_url = f"http://{USERNAME}:{PASSWORD}@localhost:3015/webui/"
|
|
print(f"\n1. Direct URL with credentials:")
|
|
print(f" {auth_url}")
|
|
|
|
# Method 2: Browser will prompt for credentials
|
|
print(f"\n2. Browser prompt:")
|
|
print(f" Visit: http://localhost:3015/webui/")
|
|
print(f" Browser will show a login prompt")
|
|
print(f" Username: {USERNAME}")
|
|
print(f" Password: {PASSWORD}")
|
|
|
|
# Method 3: Programmatic access
|
|
print(f"\n3. Programmatic access (for testing):")
|
|
credentials = base64.b64encode(f"{USERNAME}:{PASSWORD}".encode()).decode()
|
|
headers = {"Authorization": f"Basic {credentials}"}
|
|
|
|
try:
|
|
response = requests.get(WEBUI_URL, headers=headers)
|
|
print(f" Status: {response.status_code}")
|
|
if response.status_code == 200:
|
|
print(" ✅ Web UI accessible with Basic Auth!")
|
|
except Exception as e:
|
|
print(f" ❌ Error: {e}")
|
|
|
|
def test_webui_functionality():
|
|
"""Test Web UI functionality with authentication"""
|
|
print("\n=== TESTING WEB UI FUNCTIONALITY ===")
|
|
|
|
credentials = base64.b64encode(f"{USERNAME}:{PASSWORD}".encode()).decode()
|
|
headers = {"Authorization": f"Basic {credentials}"}
|
|
|
|
# Test main Web UI page
|
|
try:
|
|
response = requests.get(WEBUI_URL, headers=headers)
|
|
if response.status_code == 200:
|
|
print("✅ Web UI main page: Accessible")
|
|
|
|
# Check if it contains expected elements
|
|
content = response.text
|
|
if "Search" in content:
|
|
print("✅ Search functionality: Present")
|
|
if "Upload" in content:
|
|
print("✅ Upload functionality: Present")
|
|
if "Documents" in content:
|
|
print("✅ Documents management: Present")
|
|
else:
|
|
print(f"❌ Web UI access failed: {response.status_code}")
|
|
except Exception as e:
|
|
print(f"❌ Web UI test error: {e}")
|
|
|
|
def show_authentication_methods():
|
|
"""Show different authentication methods"""
|
|
print("\n=== AUTHENTICATION METHODS ===")
|
|
print("\nLightRAG uses TWO authentication systems:")
|
|
|
|
print("\n1. Web UI Authentication:")
|
|
print(" - Method: HTTP Basic Authentication")
|
|
print(" - Credentials: jleu3482 / jleu1212")
|
|
print(" - How to use: Browser will prompt for credentials")
|
|
|
|
print("\n2. API Authentication:")
|
|
print(" - Method: API Key in X-API-Key header")
|
|
print(" - Key: jleu1212")
|
|
print(" - How to use: Include 'X-API-Key: jleu1212' in API requests")
|
|
|
|
print("\n3. Why you might think login is failing:")
|
|
print(" - No login form: Web UI uses browser's built-in Basic Auth prompt")
|
|
print(" - If you enter wrong credentials, browser shows error immediately")
|
|
print(" - If you cancel the prompt, you get 401 Unauthorized")
|
|
|
|
def open_webui_in_browser():
|
|
"""Try to open Web UI in browser"""
|
|
print("\n=== OPENING WEB UI IN BROWSER ===")
|
|
|
|
try:
|
|
# Create the authenticated URL
|
|
auth_url = f"http://{USERNAME}:{PASSWORD}@localhost:3015/webui/"
|
|
print(f"Opening: {auth_url}")
|
|
|
|
# Try to open in browser
|
|
webbrowser.open(auth_url)
|
|
print("✅ Browser opened with Web UI")
|
|
print(" If it doesn't work, manually copy the URL above")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Could not open browser automatically: {e}")
|
|
print(f" Please manually visit: http://localhost:3015/webui/")
|
|
print(f" Use credentials: {USERNAME} / {PASSWORD}")
|
|
|
|
def main():
|
|
print("LightRAG Web UI Access Guide")
|
|
print("=" * 60)
|
|
|
|
# Show authentication methods
|
|
show_authentication_methods()
|
|
|
|
# Demonstrate Web UI access
|
|
demonstrate_webui_access()
|
|
|
|
# Test functionality
|
|
test_webui_functionality()
|
|
|
|
# Try to open in browser
|
|
open_webui_in_browser()
|
|
|
|
print("\n" + "=" * 60)
|
|
print("SUMMARY")
|
|
print("=" * 60)
|
|
|
|
print("\n✅ Your login credentials ARE WORKING:")
|
|
print(f" Username: {USERNAME}")
|
|
print(f" Password: {PASSWORD}")
|
|
|
|
print("\n🚨 The 'login failure' you're experiencing is likely because:")
|
|
print(" - Web UI uses Basic Authentication (browser prompt)")
|
|
print(" - There is NO login form to fill out")
|
|
print(" - Browser shows a popup for credentials")
|
|
|
|
print("\n📋 To access Web UI:")
|
|
print(" 1. Visit: http://localhost:3015/webui/")
|
|
print(" 2. Browser will show a login popup")
|
|
print(" 3. Enter the credentials above")
|
|
print(" 4. Click OK or Login")
|
|
|
|
print("\n🎯 If you still have issues:")
|
|
print(" - Clear browser cache and try again")
|
|
print(" - Try a different browser")
|
|
print(" - Use the direct URL: http://jleu3482:jleu1212@localhost:3015/webui/")
|
|
|
|
if __name__ == "__main__":
|
|
main() |