diff --git a/lightrag/api/README-zh.md b/lightrag/api/README-zh.md index 839aa2ef..48d822d0 100644 --- a/lightrag/api/README-zh.md +++ b/lightrag/api/README-zh.md @@ -201,8 +201,7 @@ LightRAG API 服务器使用基于 HS256 算法的 JWT 认证。要启用安全 ```bash # JWT 认证 -AUTH_USERNAME=admin # 登录名 -AUTH_PASSWORD=admin123 # 密码 +AUTH_ACCOUNTS='admin:admin123,user1:pass456' # 登录帐号与密码 TOKEN_SECRET=your-key # JWT 密钥 TOKEN_EXPIRE_HOURS=4 # 过期时间 ``` diff --git a/lightrag/api/README.md b/lightrag/api/README.md index e042fd46..bdfe0a29 100644 --- a/lightrag/api/README.md +++ b/lightrag/api/README.md @@ -203,8 +203,7 @@ LightRAG API Server implements JWT-based authentication using HS256 algorithm. T ```bash # For jwt auth -AUTH_USERNAME=admin # login name -AUTH_PASSWORD=admin123 # password +AUTH_ACCOUNTS='admin:admin123,user1:pass456' # login name and password, separated by comma TOKEN_SECRET=your-key # JWT key TOKEN_EXPIRE_HOURS=4 # expire duration ``` diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index fe0e416e..9a03e17f 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -56,6 +56,8 @@ load_dotenv(".env") config = configparser.ConfigParser() config.read("config.ini") +# Global authentication configuration +auth_configured = bool(auth_handler.accounts) def create_app(args): # Setup logging @@ -426,9 +428,7 @@ def create_app(args): try: pipeline_status = await get_namespace_data("pipeline_status") - username = os.getenv("AUTH_USERNAME") - password = os.getenv("AUTH_PASSWORD") - if not (username and password): + if not auth_configured: auth_mode = "disabled" else: auth_mode = "enabled"