跳到主要内容
版本:3.8.x

权限策略示例

完全访问所有资源​

此策略授予对 API7 Enterprise 中所有资源和操作的不受限访问。resources 和 actions 中的 <.*> 通配符都表示“全部”。这是权限最广的策略,通常仅供超级管理员使用。

{
"statement": [
{
"resources": [
"<.*>"
],
"actions": [
"<.*>"
],
"effect": "allow"
}
]
}

只读所有资源​

此策略允许用户查看所有资源,但不允许进行更改。actions 限制为包含“Get”的操作,通常对应只读操作。它适用于需要查看整个系统但不具备修改权限的角色。

{
"statement": [
{
"resources": [
"<.*>"
],
"actions": [
"<.*>Get<.*>"
],
"effect": "allow"
}
]
}

只读指定网关组​

此策略授予对指定网关组列表及其中已发布服务的只读访问。它使用唯一的网关组 ID 标识各项资源,适用于需要监控生产或测试等特定环境、但不能修改配置的用户。

{
"statement": [
{
"resources": [
"arn:api7:gateway:gatewaygroup/{gateway group id 1}",
"arn:api7:gateway:gatewaygroup/{gateway group id 2}"
],
"actions": [
"<.*>Get<.*>"
],
"effect": "allow"
},
{
"resources": [
"arn:api7:gateway:gatewaygroup/{gateway group id 1}/publishedservice/<.*>",
"arn:api7:gateway:gatewaygroup/{gateway group id 2}/publishedservice/<.*>"
],
"actions": [
"<.*>Get<.*>"
],
"effect": "allow"
}
]
}

完全访问指定网关组​

此策略提供对指定网关组及其关联服务的完全控制。策略中的多个语句以“OR”关系组合,即任意语句允许某项操作时,该操作便被允许。它适用于生产运维团队等特定环境的管理员。

{
"statement": [
{
"resources": [
"arn:api7:gateway:gatewaygroup/{gateway group id 1}",
"arn:api7:gateway:gatewaygroup/{gateway group id 2}"
],
"actions": [
"<.*>"
],
"effect": "allow"
},
{
"resources": [
"arn:api7:gateway:gatewaygroup/{gateway group id 1}/publishedservice/<.*>",
"arn:api7:gateway:gatewaygroup/{gateway group id 2}/publishedservice/<.*>"
],
"actions": [
"<.*>"
],
"effect": "allow"
}
]
}

完全访问指定网关组(消费者凭据除外)​

此策略授予对指定网关组的广泛权限,但明确禁止管理消费者凭据。它展示了“拒绝优先于允许”的原则,即对于同一资源和操作,deny 效果优先于任何 allow 语句。这是保护敏感消费者数据的重要安全措施。

{
"statement": [
{
"resources": [
"arn:api7:gateway:gatewaygroup/{gateway group id 1}",
"arn:api7:gateway:gatewaygroup/{gateway group id 2}"
],
"actions": [
"<.*>"
],
"effect": "allow"
},
{
"resources": [
"arn:api7:gateway:gatewaygroup/{gateway group id 1}/publishedservice/<.*>",
"arn:api7:gateway:gatewaygroup/{gateway group id 2}/publishedservice/<.*>"
],
"actions": [
"<.*>"
],
"effect": "allow"
},
{
"resources": [
"arn:api7:gateway:gatewaygroup/<.*>/consumer/<.*>"
],
"actions": [
"gateway:GetConsumerCredential",
"gateway:UpdateConsumerCredential",
"gateway:DeleteConsumerCredential"
],
"effect": "deny"
}
]
}

服务管理员​

此策略适用于可在所有网关组中管理特定服务的“服务管理员”角色,包括修改服务模板、发布服务以及在网关组之间同步服务。它授予对指定服务模板及其对应已发布服务的广泛权限,同时提供对网关组和全局插件规则所需的读取权限,以避免冲突。

{
"statement": [
{
"resources": [
"arn:api7:gateway:servicetemplate/{service template id}"
],
"actions": [
"<.*>"
],
"effect": "allow"
},
{
"resources": [
"arn:api7:gateway:gatewaygroup/<.*>/publishedservice/{service template id}"
],
"actions": [
"<.*>"
],
"effect": "allow"
},
{
"resources": [
"arn:api7:gateway:gatewaygroup/<.*>"
],
"actions": [
"gateway:GetGatewayGroup",
"gateway:GetGlobalPluginRule",
"gateway:GetPluginMetadata"
],
"effect": "allow"
}
]
}

你也可以使用标签,更动态、可扩展地管理多个服务。此策略授予相同的服务管理权限,但使用 MatchLabel 条件将权限应用于所有带有 team: enterprise 标签的服务。

{
"statement": [
{
"resources": [
"arn:api7:gateway:servicetemplate/<.*>"
],
"actions": [
"<.*>"
],
"conditions": {
"service_label": {
"type": "MatchLabel",
"options": {
"key": "team",
"operator": "exact_match",
"value": "enterprise"
}
}
},
"effect": "allow"
},
{
"resources": [
"arn:api7:gateway:gatewaygroup/<.*>/publishedservice/<.*>"
],
"actions": [
"<.*>"
],
"conditions": {
"service_label": {
"type": "MatchLabel",
"options": {
"key": "team",
"operator": "exact_match",
"value": "enterprise"
}
}
},
"effect": "allow"
},
{
"resources": [
"arn:api7:gateway:gatewaygroup/<.*>"
],
"actions": [
"gateway:GetGatewayGroup"
],
"effect": "allow"
}
]
}

管理自定义插件​

此策略授予管理网关设置中自定义插件的权限。它允许任何包含“CustomPlugin”的操作,从而提供对自定义插件整个生命周期的完全控制。

{
"statement": [
{
"resources": [
"arn:api7:gateway:gatewaysetting/*"
],
"actions": [
"gateway:<.*>CustomPlugin<.*>"
],
"effect": "allow"
}
]
}

角色管理员​

此策略适用于负责用户和角色管理的“角色管理员”。它授予管理用户、角色和权限策略的全部权限,允许邀请或删除用户、重置密码、设计自定义角色,以及为用户分配角色。

{
"statement": [
{
"resources": [
"arn:api7:iam:user/<.*>"
],
"actions": [
"<.*>"
],
"effect": "allow"
},
{
"resources": [
"arn:api7:iam:role/<.*>"
],
"actions": [
"<.*>"
],
"effect": "allow"
},
{
"resources": [
"arn:api7:iam:permissionpolicy/<.*>"
],
"actions": [
"<.*>"
],
"effect": "allow"
}
]
}

创建并管理生产网关组​

此策略允许用户创建新的网关组,并完全管理带有“production”标签的现有网关组。conditions 块筛选权限范围,确保用户只能影响带有指定标签的资源。这是一种实施特定环境访问控制的有效方式。

{
"statement": [
{
"resources": [
"arn:api7:gateway:gatewaygroup/<.*>"
],
"actions": [
"<.*>"
],
"conditions": {
"gateway_group_label": {
"type": "MatchLabel",
"options": {
"key": "type",
"operator": "exact_match",
"value": "production"
}
}
},
"effect": "allow"
},
{
"resources": [
"arn:api7:gateway:gatewaygroup/*"
],
"actions": [
"gateway:CreateGatewayGroup"
],
"effect": "allow"
}
]
}

具有许可证更新限制的完全资源访问​

此策略授予用户对所有资源的广泛访问权限,同时明确禁止更新许可证。这是“拒绝优先于允许”规则的另一个示例,也是一种防止未经授权更改许可证等关键系统设置的常见安全实践。deny 语句确保即使具备对所有资源的完全 allow 权限,特定的 UpdateLicense 操作仍被禁止。

{
"statement": [
{
"resources": [
"<.*>"
],
"actions": [
"<.*>"
],
"effect": "allow"
},
{
"resources": [
"arn:api7:iam:organization/*"
],
"actions": [
"iam:UpdateLicense"
],
"effect": "deny"
}
]
}

其他资源​