security: 配置文件模板化 — base_config.yaml 不再入库
- base_config.yaml → .gitignore (含真实密码不入库) - 新增 base_config.yaml.example 模板 (password: CHANGE_ME) - InitService: 检测缺失时自动从模板复制 - 首次启动自动创建配置文件 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -119,9 +119,18 @@ class InitService:
|
||||
self.configs['base'] = yaml.safe_load(f)
|
||||
logger.debug("基础配置加载成功")
|
||||
else:
|
||||
logger.warning("基础配置文件不存在,使用默认配置")
|
||||
self.configs['base'] = self._get_default_base_config()
|
||||
self._save_config(base_config_file, self.configs['base'])
|
||||
# 从模板复制
|
||||
template = self.config_path / "base_config.yaml.example"
|
||||
if template.exists():
|
||||
import shutil
|
||||
shutil.copy(template, base_config_file)
|
||||
logger.info(f"📋 从模板创建配置文件: {base_config_file}")
|
||||
with open(base_config_file, 'r', encoding='utf-8') as f:
|
||||
self.configs['base'] = yaml.safe_load(f)
|
||||
else:
|
||||
logger.warning("基础配置文件不存在,使用默认配置")
|
||||
self.configs['base'] = self._get_default_base_config()
|
||||
self._save_config(base_config_file, self.configs['base'])
|
||||
|
||||
# 加载权限规则
|
||||
permission_file = self.config_path / "permission_rules.yaml"
|
||||
|
||||
Reference in New Issue
Block a user