feat(tenant): optional legacy auto-create API key on tenant creation

Add a tenant.auto_create_api_key setting (env
WEKNORA_TENANT_AUTO_CREATE_API_KEY, default false) that restores the
pre-break-change behaviour of minting a full_access API key when a
tenant is created and returning its plaintext token in the create
response (data.api_key).

- system_setting: register tenant.auto_create_api_key bool spec
- handler: gate auto key creation behind the setting; embed the token
  via tenantWithAPIKey without re-adding a persisted api_key column;
  key-creation failures log a warning and do not fail tenant creation
- client: add optional Tenant.APIKey field populated only on create
- docs/env: document the switch (.env.example, docker-compose,
  tenant.md, regenerated swagger)
This commit is contained in:
wizardchen
2026-07-10 15:46:12 +08:00
committed by lyingbug
parent 38aacc3113
commit b4b63a0c1f
9 changed files with 307 additions and 10 deletions
+8
View File
@@ -527,6 +527,14 @@ WEKNORA_SANDBOX_TIMEOUT=60
# < 0 :彻底关闭限额(不建议在共享部署中使用)
# WEKNORA_TENANT_MAX_OWNED_PER_USER=
# 创建租户时是否自动生成一个全量权限(full_access)的 API Key,
# 并在「创建租户」接口的响应中返回其明文 token(字段 api_key)。
# 用于兼容旧版本「创建租户即下发默认 API Key」的行为(破坏性变更的回退开关)。
# - true :创建租户时自动创建 full_access API Key 并返回 token
# - false(默认):不自动创建,需通过 API Key 管理页/接口显式创建
# 也可在系统设置中以 tenant.auto_create_api_key 实时调整,无需重启。
# WEKNORA_TENANT_AUTO_CREATE_API_KEY=false
# APK 镜像源设置(可选)
APK_MIRROR_ARG=mirrors.tencent.com