yangdx commited on
Commit
5c8b125
·
2 Parent(s): 9a8a211 79cb7e5

Merge branch 'main' into sort-file

Browse files
lightrag/api/README-zh.md CHANGED
@@ -201,8 +201,7 @@ LightRAG API 服务器使用基于 HS256 算法的 JWT 认证。要启用安全
201
 
202
  ```bash
203
  # JWT 认证
204
- AUTH_USERNAME=admin # 登录名
205
- AUTH_PASSWORD=admin123 # 密码
206
  TOKEN_SECRET=your-key # JWT 密钥
207
  TOKEN_EXPIRE_HOURS=4 # 过期时间
208
  ```
 
201
 
202
  ```bash
203
  # JWT 认证
204
+ AUTH_ACCOUNTS='admin:admin123,user1:pass456' # 登录帐号与密码
 
205
  TOKEN_SECRET=your-key # JWT 密钥
206
  TOKEN_EXPIRE_HOURS=4 # 过期时间
207
  ```
lightrag/api/README.md CHANGED
@@ -203,8 +203,7 @@ LightRAG API Server implements JWT-based authentication using HS256 algorithm. T
203
 
204
  ```bash
205
  # For jwt auth
206
- AUTH_USERNAME=admin # login name
207
- AUTH_PASSWORD=admin123 # password
208
  TOKEN_SECRET=your-key # JWT key
209
  TOKEN_EXPIRE_HOURS=4 # expire duration
210
  ```
 
203
 
204
  ```bash
205
  # For jwt auth
206
+ AUTH_ACCOUNTS='admin:admin123,user1:pass456' # login name and password, separated by comma
 
207
  TOKEN_SECRET=your-key # JWT key
208
  TOKEN_EXPIRE_HOURS=4 # expire duration
209
  ```
lightrag/api/lightrag_server.py CHANGED
@@ -56,6 +56,9 @@ load_dotenv(".env")
56
  config = configparser.ConfigParser()
57
  config.read("config.ini")
58
 
 
 
 
59
 
60
  def create_app(args):
61
  # Setup logging
@@ -426,9 +429,7 @@ def create_app(args):
426
  try:
427
  pipeline_status = await get_namespace_data("pipeline_status")
428
 
429
- username = os.getenv("AUTH_USERNAME")
430
- password = os.getenv("AUTH_PASSWORD")
431
- if not (username and password):
432
  auth_mode = "disabled"
433
  else:
434
  auth_mode = "enabled"
 
56
  config = configparser.ConfigParser()
57
  config.read("config.ini")
58
 
59
+ # Global authentication configuration
60
+ auth_configured = bool(auth_handler.accounts)
61
+
62
 
63
  def create_app(args):
64
  # Setup logging
 
429
  try:
430
  pipeline_status = await get_namespace_data("pipeline_status")
431
 
432
+ if not auth_configured:
 
 
433
  auth_mode = "disabled"
434
  else:
435
  auth_mode = "enabled"