做企业管理员初始化
这篇面向 ChatGPT Enterprise admins,用来在 workspace 中设置 Codex。
这篇面向 ChatGPT Enterprise admins,用来在 workspace 中设置 Codex。
官方截图:
https://developers.openai.com/images/codex/codex_enterprise_admin.png
这是一份 rollout guide。更细的 policy、configuration 和 monitoring 说明见:
- Authentication:https://developers.openai.com/codex/auth
- Agent approvals & security:https://developers.openai.com/codex/agent-approvals-security
- Managed configuration:https://developers.openai.com/codex/enterprise/managed-configuration
- Governance:https://developers.openai.com/codex/enterprise/governance
Enterprise-grade security and privacy
Codex 支持 ChatGPT Enterprise security features,包括:
- enterprise data 不用于训练。
- App、CLI 和 IDE 支持 Zero Data Retention,code 留在 developer environment。
- residency 和 retention 遵循 ChatGPT Enterprise policies。
- granular user access controls。
- data encryption at rest:AES-256。
- data encryption in transit:TLS 1.2+。
- 通过 ChatGPT Compliance API 提供 audit logging。
security controls 和 runtime protections 见:
https://developers.openai.com/codex/agent-approvals-security
Zero Data Retention 说明:
https://platform.openai.com/docs/guides/your-data#zero-data-retention
更广的 enterprise security overview 见 Codex security white paper:
https://trust.openai.com/?itemUid=382f924d-54f3-43a8-a9df-c39e6c959958&source=click
Pre-requisites: Determine owners and rollout strategy
rollout 期间,团队成员可能分别负责不同集成环节。建议先明确这些 owners:
| Owner | 职责 |
|---|---|
| ChatGPT Enterprise workspace owner | 必须由它配置 workspace 中的 Codex settings。 |
| Security owner | 决定 Codex 的 agent permissions settings。 |
| Analytics owner | 把 analytics 和 compliance APIs 接入数据管线。 |
先决定要使用哪些 Codex surfaces:
| Surface | 说明 |
|---|---|
| Codex local | 包括 Codex app、CLI 和 IDE extension。agent 在 developer 电脑上的 sandbox 中运行。 |
| Codex cloud | 包括 hosted Codex features,例如 Codex cloud、iOS、Code Review,以及由 Slack integration 或 Linear integration 创建的 tasks。agent 在 hosted container 中远程运行,并使用你的 codebase。 |
| Both | 同时使用 local 和 cloud。 |
你可以启用 local、cloud 或两者,并用 workspace settings 和 role-based access control (RBAC) 控制访问。
Step 1: Enable Codex in your workspace
在 ChatGPT Enterprise workspace settings 中配置 Codex access:
https://chatgpt.com/admin/settings
路径是:
Workspace Settings > Settings and PermissionsCodex local
新的 ChatGPT Enterprise workspaces 默认启用 Codex local。
如果你不是 ChatGPT workspace owner,可以安装 Codex 并用 work email 登录,测试自己是否有权限:
https://developers.openai.com/codex/quickstart
打开:
Allow members to use Codex Local这会允许指定 users 使用 Codex app、CLI 和 IDE extension。
如果 toggle 关闭,尝试使用 Codex app、CLI 或 IDE 的 users 会看到:
403 - Unauthorized. Contact your ChatGPT administrator for access.Enable device code authentication for Codex CLI
当 developers 在 non-interactive environment 中使用 Codex CLI,例如 remote development box,允许他们用 device code 登录。
认证详情:
https://developers.openai.com/codex/auth/
官方截图:
https://developers.openai.com/images/codex/enterprise/local-toggle-config.png
Codex cloud
前置要求
Codex cloud 需要 GitHub cloud-hosted repositories。
如果 codebase 在 on-premises,或不在 GitHub 上,可以使用 Codex SDK 在自己的 infrastructure 上构建类似 workflows。
作为 admin 设置 Codex 时,你必须对组织中常用 repositories 拥有 GitHub access。如果没有必要权限,请和 engineering team 中有权限的人协作。
Enable Codex cloud in workspace settings
在 Workspace Settings > Settings and Permissions 的 Codex section 中,先打开 ChatGPT GitHub Connector。
要为 workspace 启用 Codex cloud,打开:
Allow members to use Codex cloud启用后,users 可以从 ChatGPT 左侧 navigation panel 直接访问 Codex。
注意:Codex 可能需要最多 10 分钟才会出现在 ChatGPT 中。
Enable Codex Slack app to post answers on task completion
task 完成时,Codex 可以把完整 answer 发回 Slack。否则,Codex 只会发 task link。
详情:
https://developers.openai.com/codex/integrations/slack
Enable Codex agent to access the internet
默认情况下,Codex cloud agents 在 runtime 中没有 internet access,这有助于防范 prompt injection 等 security 和 safety risks。
这个设置允许 users:
- 使用 common software dependency domains allowlist。
- 添加 domains 和 trusted sites。
- 指定 allowed HTTP methods。
internet access 的 security implications 和 runtime controls 见:
https://developers.openai.com/codex/agent-approvals-security
官方截图:
https://developers.openai.com/images/codex/enterprise/cloud-toggle-config.png
Step 2: Set up custom roles (RBAC)
用 RBAC 控制 Codex local 和 Codex cloud 的 granular permissions。
官方截图:
https://developers.openai.com/images/codex/enterprise/rbac_custom_roles.png
What RBAC lets you do
Workspace Owners 可以在 ChatGPT admin settings 中用 RBAC:
- 为未分配 custom role 的 users 设置 default role。
- 创建包含 granular permissions 的 custom roles。
- 给 Groups 分配一个或多个 custom roles。
- 通过 SCIM 自动把 users sync 到 Groups。
- 从 Custom Roles tab 统一管理 roles。
Users 可以继承多个 roles,permissions 会解析为这些 roles 中最 permissive,也就是 least restrictive 的 access。
Create a Codex Admin group
建议创建专门的 "Codex Admin" group,而不是把 Codex administration 授予太宽泛的人群。
下面 toggle 会授予 Codex Admin role:
Allow members to administer CodexCodex Admins 可以:
- 查看 Codex workspace analytics。
- 打开 Codex Policies page,管理 cloud-managed
requirements.tomlpolicies。 - 把这些 managed policies 分配给 user groups,或配置 default fallback policy。
- 管理 Codex cloud environments,包括 editing 和 deleting environments。
这个 role 应给负责 Codex rollout、policy management 和 governance 的少数 admins。普通 Codex users 不需要这个 role。启用这个 toggle 不要求你启用 Codex cloud。
推荐 rollout pattern:
- 创建 "Codex Users" group,放入应该使用 Codex 的人。
- 单独创建 "Codex Admin" group,放入少数负责 Codex settings 和 policies 的人。
- 只给 "Codex Admin" group 分配启用了 Allow members to administer Codex 的 custom role。
- 把 "Codex Admin" group membership 限制在 workspace owners,或指定的 platform、IT、governance operators。
- 如果使用 SCIM,用 identity provider 支撑 "Codex Admin" group,让 membership changes 可审计并集中管理。
这种分离有利于 rollout,同时把 analytics、environment management 和 policy deployment 限制在 trusted admins。
RBAC 细节和完整 permission model:
https://help.openai.com/en/articles/11750701-rbac
Step 3: Configure Codex local requirements
Codex Admins 可以从 Codex Policies page 部署 admin-enforced requirements.toml policies。
适合场景:你想给不同 groups 应用不同 local Codex constraints,但还不想先分发 device-level files。
managed policy 使用和 Managed configuration 中相同的 requirements.toml format,可定义:
- allowed approval policies
- sandbox modes
- web search behavior
- MCP server allowlists
- feature pins
- restrictive command rules
要禁用 Browser Use、in-app browser 或 Computer Use,见:
https://developers.openai.com/codex/enterprise/managed-configuration#pin-feature-flags
官方截图:
https://developers.openai.com/images/codex/enterprise/policies_and_configurations_page.png
推荐设置:
- 为大多数 users 创建 baseline policy;只有需要时再创建 stricter 或 more permissive variants。
- 把每个 managed policy 分配给指定 user group,并为其他人配置 default fallback policy。
- 仔细排序 group rules。如果 user 匹配多个 group-specific rules,第一个 matching rule 生效。
- 把每个 policy 当作该 group 的完整 profile。Codex 不会从后续 matching group rules 中补缺失 fields。
这些 cloud-managed policies 会在 users 用 ChatGPT 登录时应用到 Codex local surfaces,包括 Codex app、CLI 和 IDE extension。
Example requirements.toml policies
用 cloud-managed requirements.toml policies 为每个 group enforce guardrails。下面 snippets 是可调整示例,不是必须设置。
官方截图:
https://developers.openai.com/images/codex/enterprise/example_policy.png
限制 standard local rollout 的 web search、sandbox mode 和 approvals:
allowed_web_search_modes = ["disabled", "cached"]
allowed_sandbox_modes = ["workspace-write"]
allowed_approval_policies = ["on-request"]禁用 Browser Use、in-app browser 和 Computer Use:
[features]
browser_use = false
in_app_browser = false
computer_use = false添加 restrictive command rule,用于 block 或 gate 特定 commands:
[rules]
prefix_rules = [
{ pattern = [{ token = "git" }, { any_of = ["push", "commit"] }], decision = "prompt", justification = "Require review before mutating remote history." },
]这些示例可以单独使用,也可以合并进某个 group 的 single managed policy。exact keys、precedence 和更多 examples 见:
- Managed configuration:https://developers.openai.com/codex/enterprise/managed-configuration
- Agent approvals & security:https://developers.openai.com/codex/agent-approvals-security
Checking user policies
workflow 末尾的 policy lookup tools 可以确认某个 user 适用哪条 managed policy。你可以按 group 检查 policy assignment,也可以输入 user email 检查。
官方截图:
https://developers.openai.com/images/codex/enterprise/policy_lookup.png
如果你计划限制 local clients 的 login method 或 workspace,见 Authentication 中的 admin-managed authentication restrictions。
Step 4: Standardize local configuration with Team Config
希望组织内统一 Codex 行为的 teams,可以用 Team Config 共享 defaults、rules 和 skills,避免在每台设备重复设置。
Team Config settings 可以 check into repository 的 .codex directory。用户打开该 repository 时,Codex 会自动读取 Team Config settings。
建议从 highest-traffic repositories 开始使用 Team Config,让团队在最常用的地方获得一致行为。
| Type | Path | 用途 |
|---|---|---|
| Config basics | config.toml | 设置 sandbox mode、approvals、model、reasoning effort 等 defaults。 |
| Rules | rules/ | 控制 Codex 可以在 sandbox 外运行哪些 commands。 |
| Skills | skills/ | 为团队提供 shared skills。 |
locations 和 precedence:
https://developers.openai.com/codex/config-basic#configuration-precedence
Step 5: Configure Codex cloud usage (if enabled)
这一步覆盖启用 Codex cloud workspace toggle 后的 repository 和 environment setup。
Connect Codex cloud to repositories
- 打开 Codex,选择 Get started。
- 选择 Connect to GitHub,安装 ChatGPT GitHub Connector;如果之前已经连接 GitHub 到 ChatGPT,则使用已有连接。
- 安装或连接 ChatGPT GitHub Connector。
- 选择 ChatGPT Connector 的 installation target,通常是主要 organization。
- 允许要连接到 Codex 的 repositories。
对于 GitHub Enterprise Managed Users (EMU),organization owner 必须先为 organization 安装 Codex GitHub App,users 才能在 Codex cloud 中连接 repositories。
更多说明:
https://developers.openai.com/codex/cloud/environments
Codex 为每次操作使用 short-lived、least-privilege GitHub App installation tokens,并尊重用户现有 GitHub repository permissions 和 branch protection rules。
Configure IP addresses
如果 GitHub organization 控制 apps 用来连接的 IP addresses,确保包含这些 egress IP ranges。
这些 IP ranges 可能变化。建议自动检查并根据最新值更新 allow list。
Enable code review with Codex cloud
要允许 Codex 在 GitHub 上执行 code reviews,打开:
https://chatgpt.com/codex/settings/code-review
你可以在 repository level 配置 code review。Users 也可以为自己的 PRs 启用 auto review,并选择 Codex 何时自动触发 review。
更多说明:
https://developers.openai.com/codex/integrations/github
用 overview page 确认 workspace 已开启 code review,并查看可用 review controls。
官方截图:
- overview:https://developers.openai.com/images/codex/enterprise/code_review_settings_overview.png
- automatic code review settings:https://developers.openai.com/images/codex/enterprise/auto_code_review_settings.png
- review triggers:https://developers.openai.com/images/codex/enterprise/review_triggers.png
Configure Codex security
Codex Security 帮助 engineering 和 security teams 在 connected GitHub repositories 中 find、confirm 和 remediate likely vulnerabilities。
高层能力:
- scan connected repositories commit by commit。
- rank likely findings,并在可能时 confirm。
- 展示带 evidence、criticality 和 suggested remediation 的 structured findings。
- 允许 teams refine repository threat model,以提升 prioritization 和 review quality。
setup、scan creation、findings review 和 threat model guidance:
https://developers.openai.com/codex/security/setup
product overview:
https://developers.openai.com/codex/security
integration docs:
- Slack:https://developers.openai.com/codex/integrations/slack
- GitHub:https://developers.openai.com/codex/integrations/github
- Linear:https://developers.openai.com/codex/integrations/linear
Step 6: Set up governance and observability
Codex 为 enterprise teams 提供 adoption 和 impact visibility。建议尽早设置 governance,便于跟踪 adoption、调查 issues,并支持 compliance workflows。
Codex governance typically uses
- Analytics Dashboard:快速 self-serve visibility。
- Analytics API:programmatic reporting 和 business intelligence integration。
- Compliance API:audit 和 investigation workflows。
推荐基础配置
- 指定 adoption reporting owner。
- 指定 audit and compliance review owner。
- 定义 review cadence。
- 决定 success looks like。
Analytics API setup steps
设置 Analytics API key:
- 以 owner 或 admin 身份登录 OpenAI API Platform Portal,并选择正确 organization。
- 打开 API keys page。
- 创建一个专用于 Codex Analytics 的 new secret key,并起一个清晰名称,例如
Codex Analytics API。 - 为 organization 选择合适 project。如果只有一个 project,default project 即可。
- 设置 key permissions 为 Read only,因为这个 API 只读取 analytics data。
- 复制 key value 并安全保存;它只能查看一次。
- 给
support@openai.com发邮件,请求把该 key scope 限制为codex.enterprise.analytics.read。等待 OpenAI 确认 API key 已有 Codex Analytics API access。
官方截图:
https://developers.openai.com/images/codex/codex_analytics_key.png
使用 Analytics API key:
- 在 ChatGPT Admin console 的 Workspace details 中找到
workspace_id。 - 使用 Platform API key 调用
https://api.chatgpt.com/v1/analytics/codex,并在 path 中包含workspace_id。 - 选择 endpoint:
/workspaces/{workspace_id}/usage
/workspaces/{workspace_id}/code_reviews
/workspaces/{workspace_id}/code_review_responses- 需要时用
start_time和end_time设置 reporting date range。 - 如果 response 跨多页,用
next_page获取下一页。
获取 workspace usage 的 curl 示例:
curl -H "Authorization: Bearer YOUR_PLATFORM_API_KEY" \
"https://api.chatgpt.com/v1/analytics/codex/workspaces/WORKSPACE_ID/usage"Analytics API 详情:
https://developers.openai.com/codex/enterprise/governance#analytics-api
Compliance API setup steps
设置 Compliance API key:
- 以 owner 或 admin 身份登录 OpenAI API Platform Portal,并选择正确 organization。
- 打开 API keys page。
- 创建一个专用于 Compliance API 的 new secret key,并选择 organization 对应 project。如果只有一个 project,default project 即可。
- 选择 All permissions。
- 复制 key value 并安全保存;它只能查看一次。
- 给
support@openai.com发邮件,包含:
- API key last 4 digits
- key name
- created-by name
- needed scope:
read、delete或 both
- 等待 OpenAI 确认 API key 已有 Compliance API access。
使用 Compliance API key:
- 在 ChatGPT Admin console 的 Workspace details 中找到
workspace_id。 - 使用 Compliance API:
https://api.chatgpt.com/v1/ - 在 Authorization header 中以 Bearer token 传入 Compliance API key。
- Codex-related compliance data 使用这些 endpoints:
/compliance/workspaces/{workspace_id}/logs
/compliance/workspaces/{workspace_id}/logs/{log_file_id}
/compliance/workspaces/{workspace_id}/codex_tasks
/compliance/workspaces/{workspace_id}/codex_environments- 多数 Codex compliance integrations 可以从 logs endpoint 开始,并请求
CODEX_LOG或CODEX_SECURITY_LOG这类 Codex event types。 - 用
/logs列出可用 Codex compliance log files,再用/logs/{log_file_id}下载特定文件。
列出 compliance log files 的 curl 示例:
curl -L -H "Authorization: Bearer YOUR_COMPLIANCE_API_KEY" \
"https://api.chatgpt.com/v1/compliance/workspaces/WORKSPACE_ID/logs?event_type=CODEX_LOG&after=2026-03-01T00:00:00Z"列出 Codex tasks 的 curl 示例:
curl -H "Authorization: Bearer YOUR_COMPLIANCE_API_KEY" \
"https://api.chatgpt.com/v1/compliance/workspaces/WORKSPACE_ID/codex_tasks"Compliance API 详情:
https://developers.openai.com/codex/enterprise/governance#compliance-api
Step 7: Confirm and verify setup
要验证什么
检查项:
- users 可以 sign in to Codex local,使用 ChatGPT 或 API key。
- 如果启用,users 可以 sign in to Codex cloud;Codex cloud 需要 ChatGPT sign-in。
- MFA 和 SSO requirements 符合 enterprise security policy。
- RBAC 和 workspace toggles 产生预期 access behavior。
- managed configuration 对 users 生效。
- admins 能看到 governance data。
authentication options 和 enterprise login restrictions:
https://developers.openai.com/codex/auth
当团队确认 setup 后,就可以把 Codex rollout 到更多 teams 和 organizations。