---
type: study
created: 2026-08-11
updated: 2026-08-11
sensitivity: standard
status: verified
tags: [langchain, langsmith, governance, rbac, abac, sso, scim]
topic: Organization/Workspace、RBAC/ABAC、SSO/SCIM 与审计治理
sources:
  - "https://docs.langchain.com/langsmith/abac"
  - "https://docs.langchain.com/langsmith/audit-logs"
  - "https://docs.langchain.com/langsmith/authentication-methods"
  - "https://docs.langchain.com/langsmith/jit-invite-sso"
  - "https://docs.langchain.com/langsmith/manage-organization-by-api"
  - "https://docs.langchain.com/langsmith/organization-workspace-operations"
  - "https://docs.langchain.com/langsmith/rbac"
  - "https://docs.langchain.com/langsmith/script-delete-a-workspace"
  - "https://docs.langchain.com/langsmith/script-delete-an-organization"
  - "https://docs.langchain.com/langsmith/self-host-user-management"
  - "https://docs.langchain.com/langsmith/set-up-hierarchy"
  - "https://docs.langchain.com/langsmith/set-up-resource-tags"
  - "https://docs.langchain.com/langsmith/user-management"
last_verified: 2026-08-11
---

# 组织、工作区、RBAC/ABAC 与身份治理

## 权限层级

一个用户有一个 Organization role，并在每个加入的 Workspace 中有一个 Workspace role。Organization role 管组织配置、成员、计费与 Workspace；Workspace role 管具体资源。

| 层级 | 内置角色 | 关键语义 |
| --- | --- | --- |
| Organization | Admin、Operator、User、Viewer | Admin 可管理全部并进入所有 Workspace；Viewer 不可建 PAT |
| Workspace | Admin、Editor、Viewer | Admin 管成员/Key；Editor 管大部分资源；Viewer 只读 |

Enterprise 才有 Workspace RBAC 与自定义角色；其他计划常把成员视为 Admin。Organization Admin 的权限会向全部 Workspace 提升，不能用 Workspace Viewer 降低它。限制高权限角色时先保留至少两个 break-glass 管理员。

## API Key 与 Header

- PAT 继承用户权限，适合个人工具；生产服务优先 Service Key。
- Workspace-scoped Service Key 只能访问指定 Workspace。
- Organization-scoped Service Key 访问 Workspace resource 时必须带 `X-Tenant-Id`，否则 `403`。
- 管理 Organization API 还应带 `X-Organization-Id`；不要依赖“Key 默认 Workspace”这种隐式行为。

API、Terraform 与 UI 都能改资源，生产应确定一个权威控制面并用 drift 检测，避免权限被交替覆盖。

## ABAC 求值模型

ABAC 以 Resource Tag 补充 RBAC，目前唯一支持的 `attribute_name` 是 `resource_tag_key`。Policy 结构为：

- 多个 condition group 之间是 OR；
- 同一 group 内 conditions 是 AND；
- `deny` 永远优先；
- 匹配的 `allow` 可在 RBAC 不允许时额外授权；
- 没有 ABAC match 时回退 RBAC。

`*_if_exists` 在 tag 不存在时也匹配，放在 allow 会放行未标记资源，放在 deny 会拦截未标记资源，风险很高。更安全的生产模式是先强制资源创建时打 `Application`/`Environment`/客户边界标签，再用明确 deny 保护敏感 tag。

Self-hosted ABAC 要求 Helm chart 0.11.28+、应用 0.12.1+；开启组织 feature flag 涉及直改 PostgreSQL 或全局环境变量，必须备份、审批并先在测试组织验证。

## Resource Tag

Tag 是 Workspace 内 key-value，用于组织和 ABAC。`Application` 与 `Environment` 为默认 key。它不同于 Prompt commit tag：Resource Tag 组织/授权资源，commit tag 指向 Prompt 历史版本。

只有 Workspace-scoped resource 可标记。创建 tag key、普通 tag 赋值通常需要 `workspaces:manage`；Editor 仅可对有更新权的资源应用 Application tag。删除 tag 前先检查 ABAC Policy，否则可能改变授权结果。

## SSO、JIT、Invite 与 SCIM

SSO Organization 有两个独立开关：

| JIT | Invite | 结果 |
| --- | --- | --- |
| 开 | 开 | 登录自动加入，也可预邀请 |
| 开 | 关 | 仅通过 SSO 登录自动加入 |
| 关 | 开 | 仅预邀请用户可加入 |
| 关 | 关 | 关闭自助入口，只能 SCIM/管理员流程 |

SAML-only 前必须由 SAML 会话中的管理员操作，避免 IdP 配置错误锁死组织。JIT 只作用于首次加入的用户；已有成员角色不会每次登录自动重置。

SCIM 适合主动 provisioning/deprovisioning 和近实时 group push，通常应关闭 JIT 以避免冲突。SCIM group membership 会覆盖手工/JIT role。NameID、OAuth `sub` 与 SCIM identity 要稳定一致。

SSO Groups Sync 从登录 token 的 group claim 同步，部署更轻，但用户被移出 IdP group 后要到下次登录才撤权。它与 SCIM 技术上可共存，官方建议每 Organization 选择一种，避免 precedence 难以解释。禁用 Groups Sync 不会立即移除现有 access。

## 审计

Enterprise Audit Log 记录 actor、时间、operation、resource 与成功状态，保留最长 400 天。Organization Admin/Operator 才能查看；Self-hosted 需满足版本/开关要求。对接 SIEM 时使用增量 cursor、幂等 event ID、时钟同步和传输失败告警，不能只定期手工导出。

重点审计事件：成员/角色、API Key、SSO/SCIM、ABAC Policy、数据留存、Deployment、Dataset、Prompt webhook 与删除操作。

## 自托管用户管理开关

Self-hosted 可允许 Workspace Admin 邀请组织用户、设置默认 Organization/Workspace/Role、启用 SSO group sync、禁止创建 Organization/Personal Organization/PAT。Feature flag 变更要验证已有用户和新用户两条路径，不能只测管理员账号。

## 删除 Organization/Workspace 的高风险边界

新版本 Workspace 删除已有原生能力；旧版脚本和 Organization 删除脚本会直接删除 ClickHouse materialized views/table 数据并修改 PostgreSQL tenant 记录。此操作跨多个数据库、不可逆且可能长时间占用资源。

执行前必须：完整备份、停止相关写入、精确核对 ID、导出资源清单、在相同版本副本演练；执行后校验 PostgreSQL、ClickHouse、Blob、API key、成员与 UI。禁止把“脚本退出 0”当作数据一致性证明。

