Merge branch 'main' into sort-file

This commit is contained in:
yangdx
2025-03-27 13:40:22 +08:00
3 changed files with 6 additions and 7 deletions

View File

@@ -201,8 +201,7 @@ LightRAG API 服务器使用基于 HS256 算法的 JWT 认证。要启用安全
```bash ```bash
# JWT 认证 # JWT 认证
AUTH_USERNAME=admin # 登录 AUTH_ACCOUNTS='admin:admin123,user1:pass456' # 登录帐号与密码
AUTH_PASSWORD=admin123 # 密码
TOKEN_SECRET=your-key # JWT 密钥 TOKEN_SECRET=your-key # JWT 密钥
TOKEN_EXPIRE_HOURS=4 # 过期时间 TOKEN_EXPIRE_HOURS=4 # 过期时间
``` ```

View File

@@ -203,8 +203,7 @@ LightRAG API Server implements JWT-based authentication using HS256 algorithm. T
```bash ```bash
# For jwt auth # For jwt auth
AUTH_USERNAME=admin # login name AUTH_ACCOUNTS='admin:admin123,user1:pass456' # login name and password, separated by comma
AUTH_PASSWORD=admin123 # password
TOKEN_SECRET=your-key # JWT key TOKEN_SECRET=your-key # JWT key
TOKEN_EXPIRE_HOURS=4 # expire duration TOKEN_EXPIRE_HOURS=4 # expire duration
``` ```

View File

@@ -56,6 +56,9 @@ load_dotenv(".env")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read("config.ini") config.read("config.ini")
# Global authentication configuration
auth_configured = bool(auth_handler.accounts)
def create_app(args): def create_app(args):
# Setup logging # Setup logging
@@ -426,9 +429,7 @@ def create_app(args):
try: try:
pipeline_status = await get_namespace_data("pipeline_status") pipeline_status = await get_namespace_data("pipeline_status")
username = os.getenv("AUTH_USERNAME") if not auth_configured:
password = os.getenv("AUTH_PASSWORD")
if not (username and password):
auth_mode = "disabled" auth_mode = "disabled"
else: else:
auth_mode = "enabled" auth_mode = "enabled"