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

权限策略示例

对所有资源的完全访问权限

此策略授予对 API7 企业版中所有资源和操作的无限制访问权限。resourcesactions 中的 <.*> 通配符表示“所有”。这是最宽松的策略,通常仅限于超级管理员。

{
"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"
}
]
}

对特定网关组的完全访问权限

此策略提供对特定网关组及其相关服务的完全控制。策略中的多个声明以“或”关系组合,这意味着只要有任何声明允许某个操作,该操作即被允许。这适用于特定环境的管理员,例如生产运维团队。

{
"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"
}
]
}

其他资源