chore(env): expose tenant RBAC + per-user tenant cap as env knobs

Surface two existing config.go env overrides to the canonical
deployment artifacts so operators can flip them without reading the
Go source:

* WEKNORA_TENANT_ENABLE_RBAC — observe / enforce switch for
  tenant-level role enforcement (PR 1303). Default false keeps the
  current behaviour; flip to true once role assignments have been
  audited per docs/rbac.md.
* WEKNORA_TENANT_MAX_OWNED_PER_USER — cap on tenants a single
  non-superuser can self-create. Uses the existing <0 / 0 / >0
  sentinel semantics documented on TenantConfig.MaxOwnedPerUser.

docker-compose.yml passes both through to the app container, and
.env.example gains a "Tenant / RBAC" section with the default
values and the same sentinel rules inline so the example is the
sole reference operators need.

No functional change — both env vars were already honoured by
config.go.applyAuthAndTenantDefaults.
This commit is contained in:
wizardchen
2026-05-18 20:58:27 +08:00
committed by lyingbug
parent 49f3ad185a
commit 633106c5ef
2 changed files with 22 additions and 0 deletions

View File

@@ -431,6 +431,22 @@ WEKNORA_SANDBOX_TIMEOUT=60
# 也支持 Go duration 写法(如 30s / 5m / 1h
# WEKNORA_AGENT_TOOL_APPROVAL_TIMEOUT=600
# ========== Tenant / RBAC 配置 ==========
# 启用租户级 RBAC基于 tenant_members 表的角色强制鉴权)。
# - false默认观察模式记录但不拦截便于上线初期审计角色分配
# - true开启后无 active membership 或角色不足的请求会被 403 拒绝
# 详细灰度方案见 docs/rbac.md。
# 注意:开发环境用 Air 热重载时,修改本变量需重启 dev 脚本(仅源代码变更才重读 .env
# WEKNORA_TENANT_ENABLE_RBAC=false
# 单个非超管用户可自助创建(成为 Owner的租户数上限。
# 仅统计 Owner 角色——被邀请为 Admin/Editor/Viewer 的不计入。
# 拥有 CanAccessAllTenants 的超管不受此限制。
# > 0 :启用该值作为硬上限;超出返回 429
# = 0 :使用 handler 默认值
# < 0 :彻底关闭限额(不建议在共享部署中使用)
# WEKNORA_TENANT_MAX_OWNED_PER_USER=
# APK 镜像源设置(可选)
APK_MIRROR_ARG=mirrors.tencent.com

View File

@@ -170,6 +170,12 @@ services:
# Agent LLM call timeout
- WEKNORA_AGENT_LLM_TIMEOUT=${WEKNORA_AGENT_LLM_TIMEOUT:-}
- WEKNORA_AGENT_TOOL_APPROVAL_TIMEOUT=${WEKNORA_AGENT_TOOL_APPROVAL_TIMEOUT:-}
# Tenant / RBAC详见 docs/rbac.md 与 .env.example 注释)
# - WEKNORA_TENANT_ENABLE_RBAC: 是否启用租户角色强制鉴权true / false默认 false
# - WEKNORA_TENANT_MAX_OWNED_PER_USER: 单个非超管自助创建租户的上限
# >0 强制限额;=0 走 handler 默认;<0 关闭限额(不建议共享部署使用)
- WEKNORA_TENANT_ENABLE_RBAC=${WEKNORA_TENANT_ENABLE_RBAC:-}
- WEKNORA_TENANT_MAX_OWNED_PER_USER=${WEKNORA_TENANT_MAX_OWNED_PER_USER:-}
- APK_MIRROR_ARG=${APK_MIRROR_ARG:-}
depends_on:
redis: