yangdx commited on
Commit
6936be2
·
1 Parent(s): c61b420

Fix linting

Browse files
env.example CHANGED
@@ -13,9 +13,6 @@
13
  # SSL_CERTFILE=/path/to/cert.pem
14
  # SSL_KEYFILE=/path/to/key.pem
15
 
16
- ### Security (empty for no api-key is needed)
17
- # LIGHTRAG_API_KEY=your-secure-api-key-here
18
-
19
  ### Directory Configuration
20
  # WORKING_DIR=<absolute_path_for_working_dir>
21
  # INPUT_DIR=<absolute_path_for_doc_input_dir>
@@ -158,4 +155,7 @@ AUTH_USERNAME=admin # login name
158
  AUTH_PASSWORD=admin123 # password
159
  TOKEN_SECRET=your-key-for-LightRAG-API-Server # JWT key
160
  TOKEN_EXPIRE_HOURS=4 # expire duration
161
- WHITELIST_PATHS=/login,/health # white list
 
 
 
 
13
  # SSL_CERTFILE=/path/to/cert.pem
14
  # SSL_KEYFILE=/path/to/key.pem
15
 
 
 
 
16
  ### Directory Configuration
17
  # WORKING_DIR=<absolute_path_for_working_dir>
18
  # INPUT_DIR=<absolute_path_for_doc_input_dir>
 
155
  AUTH_PASSWORD=admin123 # password
156
  TOKEN_SECRET=your-key-for-LightRAG-API-Server # JWT key
157
  TOKEN_EXPIRE_HOURS=4 # expire duration
158
+
159
+ ### API-Key to access LightRAG Server API
160
+ # LIGHTRAG_API_KEY=your-secure-api-key-here
161
+ # WHITELIST_PATHS=/health,/api/*
lightrag/api/lightrag_server.py CHANGED
@@ -41,7 +41,6 @@ from lightrag.kg.shared_storage import (
41
  get_namespace_data,
42
  get_pipeline_status_lock,
43
  initialize_pipeline_status,
44
- get_all_update_flags_status,
45
  )
46
  from fastapi.security import OAuth2PasswordRequestForm
47
  from .auth import auth_handler
@@ -453,7 +452,7 @@ def create_app(args):
453
  "core_version": core_version,
454
  "api_version": __api_version__,
455
  "auth_mode": auth_mode,
456
- }
457
 
458
  # Custom StaticFiles class to prevent caching of HTML files
459
  class NoCacheStaticFiles(StaticFiles):
 
41
  get_namespace_data,
42
  get_pipeline_status_lock,
43
  initialize_pipeline_status,
 
44
  )
45
  from fastapi.security import OAuth2PasswordRequestForm
46
  from .auth import auth_handler
 
452
  "core_version": core_version,
453
  "api_version": __api_version__,
454
  "auth_mode": auth_mode,
455
+ }
456
 
457
  # Custom StaticFiles class to prevent caching of HTML files
458
  class NoCacheStaticFiles(StaticFiles):
lightrag/api/routers/document_routes.py CHANGED
@@ -798,16 +798,19 @@ def create_document_routes(
798
  HTTPException: If an error occurs while retrieving pipeline status (500)
799
  """
800
  try:
801
- from lightrag.kg.shared_storage import get_namespace_data, get_all_update_flags_status
 
 
 
802
 
803
  pipeline_status = await get_namespace_data("pipeline_status")
804
-
805
  # Get update flags status for all namespaces
806
  update_status = await get_all_update_flags_status()
807
 
808
  # Convert to regular dict if it's a Manager.dict
809
  status_dict = dict(pipeline_status)
810
-
811
  # Add update_status to the status dictionary
812
  status_dict["update_status"] = update_status
813
 
 
798
  HTTPException: If an error occurs while retrieving pipeline status (500)
799
  """
800
  try:
801
+ from lightrag.kg.shared_storage import (
802
+ get_namespace_data,
803
+ get_all_update_flags_status,
804
+ )
805
 
806
  pipeline_status = await get_namespace_data("pipeline_status")
807
+
808
  # Get update flags status for all namespaces
809
  update_status = await get_all_update_flags_status()
810
 
811
  # Convert to regular dict if it's a Manager.dict
812
  status_dict = dict(pipeline_status)
813
+
814
  # Add update_status to the status dictionary
815
  status_dict["update_status"] = update_status
816
 
lightrag/api/utils_api.py CHANGED
@@ -35,9 +35,7 @@ for path in whitelist_paths:
35
  prefix = path[:-2]
36
  whitelist_patterns.append((prefix, True)) # (prefix, is_prefix_match)
37
  else:
38
- whitelist_patterns.append(
39
- (path, False)
40
- ) # (exact_path, is_prefix_match)
41
 
42
  # Global authentication configuration
43
  auth_username = os.getenv("AUTH_USERNAME")
@@ -70,7 +68,7 @@ def get_combined_auth_dependency(api_key: Optional[str] = None):
70
  """
71
  # Use global whitelist_patterns and auth_configured variables
72
  # whitelist_patterns and auth_configured are already initialized at module level
73
-
74
  # Only calculate api_key_configured as it depends on the function parameter
75
  api_key_configured = bool(api_key)
76
 
@@ -102,7 +100,7 @@ def get_combined_auth_dependency(api_key: Optional[str] = None):
102
  raise HTTPException(
103
  status_code=status.HTTP_401_UNAUTHORIZED, detail="Token required"
104
  )
105
-
106
  # Try API key authentication (if configured)
107
  if api_key_configured:
108
  api_key_header = request.headers.get("X-API-Key")
@@ -136,7 +134,7 @@ def get_api_key_dependency(api_key: Optional[str]):
136
  """
137
  # Use global whitelist_patterns and auth_configured variables
138
  # whitelist_patterns and auth_configured are already initialized at module level
139
-
140
  # Only calculate api_key_configured as it depends on the function parameter
141
  api_key_configured = bool(api_key)
142
 
 
35
  prefix = path[:-2]
36
  whitelist_patterns.append((prefix, True)) # (prefix, is_prefix_match)
37
  else:
38
+ whitelist_patterns.append((path, False)) # (exact_path, is_prefix_match)
 
 
39
 
40
  # Global authentication configuration
41
  auth_username = os.getenv("AUTH_USERNAME")
 
68
  """
69
  # Use global whitelist_patterns and auth_configured variables
70
  # whitelist_patterns and auth_configured are already initialized at module level
71
+
72
  # Only calculate api_key_configured as it depends on the function parameter
73
  api_key_configured = bool(api_key)
74
 
 
100
  raise HTTPException(
101
  status_code=status.HTTP_401_UNAUTHORIZED, detail="Token required"
102
  )
103
+
104
  # Try API key authentication (if configured)
105
  if api_key_configured:
106
  api_key_header = request.headers.get("X-API-Key")
 
134
  """
135
  # Use global whitelist_patterns and auth_configured variables
136
  # whitelist_patterns and auth_configured are already initialized at module level
137
+
138
  # Only calculate api_key_configured as it depends on the function parameter
139
  api_key_configured = bool(api_key)
140