From a444edd9eb1fe5e22381ad42b14a82d6a37f7293 Mon Sep 17 00:00:00 2001 From: yangdx Date: Sun, 23 Mar 2025 02:43:44 +0800 Subject: [PATCH] Added auth mode status to health check endpoint. - Introduced auth_mode in health check response - Updated App.tsx to handle guest mode logic --- lightrag/api/lightrag_server.py | 8 ++++++++ lightrag_webui/src/App.tsx | 3 ++- lightrag_webui/src/api/lightrag.ts | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index 2e091ac8..584d020f 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -417,6 +417,13 @@ def create_app(args): # Get update flags status for all namespaces update_status = await get_all_update_flags_status() + username = os.getenv("AUTH_USERNAME") + password = os.getenv("AUTH_PASSWORD") + if not (username and password): + auth_mode = "disabled" + else: + auth_mode = "enabled" + return { "status": "healthy", "working_directory": str(args.working_dir), @@ -440,6 +447,7 @@ def create_app(args): "update_status": update_status, "core_version": core_version, "api_version": __api_version__, + "auth_mode": auth_mode, } # Custom StaticFiles class to prevent caching of HTML files diff --git a/lightrag_webui/src/App.tsx b/lightrag_webui/src/App.tsx index 48d94ced..c0b6ac3d 100644 --- a/lightrag_webui/src/App.tsx +++ b/lightrag_webui/src/App.tsx @@ -61,10 +61,11 @@ function App() { try { const status = await getAuthStatus(); if (status.core_version || status.api_version) { + const isGuestMode = status.auth_mode === 'disabled' || useAuthStore.getState().isGuestMode; // Update version info while maintaining login state useAuthStore.getState().login( token, - useAuthStore.getState().isGuestMode, + isGuestMode, status.core_version, status.api_version ); diff --git a/lightrag_webui/src/api/lightrag.ts b/lightrag_webui/src/api/lightrag.ts index 21da295a..fd1f02bb 100644 --- a/lightrag_webui/src/api/lightrag.ts +++ b/lightrag_webui/src/api/lightrag.ts @@ -44,6 +44,7 @@ export type LightragStatus = { update_status?: Record core_version?: string api_version?: string + auth_mode?: 'enabled' | 'disabled' } export type LightragDocumentsScanProgress = {