企业限制 marketplace 源:写 requirements.toml,不是 config.toml
restrict_to_allowed_sources 只在 requirements.toml 生效。拦 add / install / refresh,并在运行时过滤。官方精选仓也要显式放行。
想限制同事能加哪些插件源,把规则写进企业 requirements.toml(或 MDM 的 requirements_toml_base64),不要写进 ~/.codex/config.toml。用户层同名表只是默认值,不是强制策略。
# requirements.toml,不是用户 config.toml
[marketplaces]
restrict_to_allowed_sources = true
[marketplaces.allowed_sources.company_plugins]
source = "git"
url = "https://github.com/example/company-plugins.git"
ref = "main"
[marketplaces.allowed_sources.internal_git]
source = "host_pattern"
host_pattern = '^git\.example\.com#39;
[marketplaces.allowed_sources.local_plugins]
source = "local"
path = "/opt/company/codex-plugins"
git 规则先规范化 URL,再要求仓库一致;写了 ref 就必须精确匹配。host_pattern 是正则,对着小写 Git 主机名匹配,用 ^ 和 $ 锁整机。local 必须是规范化后的绝对路径。不同规则名会跨层累加;同名规则按层覆盖字段。
restrict_to_allowed_sources = true 时:对不上的 marketplace add、插件安装、已配置 Git marketplace 刷新会被拒绝,已经配上的 marketplace 和插件也会在运行时被过滤。不要以为「早就装上了就不会被关」。
官方精选 Git marketplace(含 API key 目录)不会自动放行。要留给同事用,加一条不带 ref 的规则:
[marketplaces.allowed_sources.openai_curated]
source = "git"
url = "https://github.com/openai/plugins.git"
省略它、又没有更宽的 host 规则时,精选目录会被挡掉。捆绑插件和远端下发的工作区插件不走这条 Git 源策略。
这套限制只作用于支持 marketplace 操作的本机客户端:ChatGPT / Codex 桌面应用和 Codex CLI。不管网页或手机里的插件,也不会给 IDE 扩展加插件。整台机器关掉插件是另一条:在 requirements.toml 写 features.plugins = false。只关远程目录、留下本地插件,用 features.remote_plugin = false。