阿里云API网关(12)为员工创建子账号,实现分权管理API:使用RAM管理API

API 网关结合阿里云访问控制(RAM)来实现企业内多职员分权管理 API。API 提供者可以为员工建立子账户,并控制不同职员负责不同的 API 管理。

  • 使用 RAM 可以允许子帐号,查看、创建、管理、删除 API 分组、API、授权、流控策略等。但子帐号不是资源的所有者,其操作权限随时都可以被主帐号收回。
  • 在查看本文前,请确保您已经祥读了 RAM 帮助手册 和 API 网关 API 手册.
  • 若您不无此业务场景, 请跳过此章节。

你可以使用 RAM 的控制台 或者 API 来添加操作。

第一部分:策略管理

授权策略(Policy),来描述授权的具体内容,授权内容主要包含效力( Effect )、资源( Resource )、对资源所授予的操作权限( Action )以及限制条件( Condition )这几个基本元素。

系统授权策略

API 网关已经预置了两个系统权限,AliyunApiGatewayFullAccess和AliyunApiGatewayReadOnlyAccess,可以到 RAM 的在 RAM 控制台-策略管理 进行查看。系统预置

  • AliyunApiGatewayFullAccess: 管理员权限,拥有主帐号下包含 API 分组、API、流控策略、应用等所有资源的管理权限。
  • AliyunApiGatewayReadOnlyAccess:可以查看主帐号下包含 API 分组、API、流控策略、应用等所有资源,但不可以操作。

自定义授权策略

您可以根据需要自定义管理权限,支持更为精细化的授权,可以为某个操作,也可以是某个资源。如:API GetUsers 的编辑权限。可以在 RAM 控制台-策略管理-自定义授权策略查看已经定义好的自定义授权:自定义授权查看、创建、修改、删除方法请参照:授权策略管理
授权策略内容填写方法请参照:Policy 基本元素  Policy 语法结构 和下文的授权策略。

第二部分:授权策略

授权策略是一组权限的集合,它以一种策略语言来描述。通过给用户或群组附加授权策略,用户或群组中的所有用户就能获得授权策略中指定的访问权限。
授权策略内容填写方法请参照:Policy 基本元素 和 Policy 语法结构
示例:

  1. {
  2. "Version": "1",
  3. "Statement": [
  4. {
  5. "Action": "apigateway:Describe*",
  6. "Resource": "*",
  7. "Effect": "Allow"
  8. }
  9. ]
  10. }

此示例表示:允许所有的查看操作

Action(操作名称列表)格式为:

  1. "Action":"<service-name>:<action-name>"

其中:

  • service-name 为:阿里云产品名称,请填写 apigateway
  • action-name 为:API 接口名称,请参照下表, 支持通配符 *
  1. "Action": "apigateway:Describe*" 表示所有的查询操作
  2. " Action": "apigateway:*" 表示 API 网关所有操作

第三部分:Resource(操作对象列表)

Resource 通常指操作对象, API 网关中的 API 分组、流控策略、应用都被称为 Resource,书写格式:

  1. acs:<service-name>:<region>:<account-id>:<relative-id>

其中:

  • acs: Alibaba Cloud Service 的首字母缩写,表示阿里云的公有云平台
  • service-name 为:阿里云产品名称,请填写 apigateway
  • region: 地区信息,可以使用通配符*号来代替,*表示所有区域
  • account-id: 账号 ID,比如 1234567890123456,也可以用*代替
  • relative-id: 与 API 网关相关的资源描述部分,这部分的格式描述支持类似于一个文件路径的树状结构。

示例:

  1. acs:apigateway:$regionid:$accountid:apigroup/$groupId

书写:

  1. acs:apigateway:*:$accountid:apigroup/

请结合 API 网关的 API 手册 来查看下表

action-name资源( Resource )
AbolishApiacs:apigateway:$regionid:$accountid:apigroup/$groupId
AddTrafficSpecialControlacs:apigateway:$regionid:$accountid:trafficcontrol/$trafficcontrolid
CreateApiacs:apigateway:$regionid:$accountid:apigroup/$groupId
CreateApiGroupacs:apigateway:$regionid:$accountid:apigroup/*
CreateTrafficControlacs:apigateway:$regionid:$accountid:trafficcontrol/*
DeleteAllTrafficSpecialControlacs:apigateway:$regionid:$accountid:trafficcontrol/$trafficcontrolid
DeleteApiacs:apigateway:$regionid:$accountid:apigroup/$groupId
DeleteApiGroupacs:apigateway:$regionid:$accountid:apigroup/$groupId
DeleteDomainacs:apigateway:$regionid:$accountid:apigroup/$groupId
DeleteDomainCertificateacs:apigateway:$regionid:$accountid:apigroup/$groupId
DeleteTrafficControlacs:apigateway:$regionid:$accountid:trafficcontrol/$trafficcontrolId
DeleteTrafficSpecialControlacs:apigateway:$regionid:$accountid:trafficcontrol/$trafficcontrolId
DeployApiacs:apigateway:$regionid:$accountid:apigroup/$groupId
DescribeApiacs:apigateway:$regionid:$accountid:apigroup/$groupId
DescribeApiErroracs:apigateway:$regionid:$accountid:apigroup/$groupId
DescribeApiGroupDetailacs:apigateway:$regionid:$accountid:apigroup/$groupId
DescribeApiGroupsacs:apigateway:$regionid:$accountid:apigroup/*
DescribeApiLatencyacs:apigateway:$regionid:$accountid:apigroup/$groupId
DescribeApiQpsacs:apigateway:$regionid:$accountid:apigroup/$groupId
DescribeApiRulesacs:apigateway:$regionid:$accountid:apigroup/$groupId
DescribeApisacs:apigateway:$regionid:$accountid:apigroup/$groupId
DescribeApisByRuleacs:apigateway:$regionid:$accountid:trafficcontrol/$trafficcontrolId oracs:apigateway:$regionid:$accountid:secretkey/$secretKeyId
DescribeApiTrafficacs:apigateway:$regionid:$accountid:apigroup/$groupid
DescribeAppsByApiacs:apigateway:$regionid:$accountid:apigroup/$groupId
AddBlackListacs:apigateway:$regionid:$accountid:blacklist/*
DescribeBlackListsacs:apigateway:$regionid:$accountid:blacklist/*
DescribeDeployedApiacs:apigateway:$regionid:$accountid:apigroup/$groupId
DescribeDeployedApisacs:apigateway:$regionid:$accountid:apigroup/$groupId
DescribeDomainacs:apigateway:$regionid:$accountid:apigroup/$groupId
DescribeDomainResolutionacs:apigateway:$regionid:$accountid:apigroup/$groupId
DescribeHistoryApiacs:apigateway:$regionid:$accountid:apigroup/$groupId
DescribeHistoryApisacs:apigateway:$regionid:$accountid:apigroup/*
DescribeRulesByApiacs:apigateway:$regionid:$accountid:group/$groupId
DescribeSecretKeysacs:apigateway:$regionid:$accountid:secretkey/*
DescribeTrafficControlsacs:apigateway:$regionid:$accountid:trafficcontrol/*
ModifyApiacs:apigateway:$regionid:$accountid:apigroup/$groupId
ModifyApiGroupacs:apigateway:$regionid:$accountid:apigroup/$groupId
ModifySecretKeyacs:apigateway:$regionid:$accountid:secretkey/$secretKeyId
RecoverApiFromHistoricalacs:apigateway:$regionid:$accountid:apigroup/$groupId
RefreshDomainacs:apigateway:$regionid:$accountid:apigroup/$groupId
RemoveAccessPermissionByApisacs:apigateway:$regionid:$accountid:apigroup/$groupId
RemoveAccessPermissionByAppsacs:apigateway:$regionid:$accountid:apigroup/$groupId
RemoveAllBlackListacs:apigateway:$regionid:$accountid:blacklist/*
RemoveApiRuleacs:apigateway:$regionid:$accountid:apigroup/$groupId(acs:apigateway:$regionid:$accountid:secretkey/$secretKeyId oracs:apigateway:$regionid:$accountid:trafficcontrol/$trafficcontrolId)
RemoveAppsFromApiacs:apigateway:$regionid:$accountid:apigroup/$groupId
RemoveBlackListacs:apigateway:$regionid:$accountid:blacklist/$blacklistid
SetAccessPermissionByApisacs:apigateway:$regionid:$accountid:apigroup/$groupId
SetAccessPermissionsacs:apigateway:$regionid:$accountid:apigroup/$groupId
SetApiRuleacs:apigateway:$regionid:$accountid:apigroup/$groupId(acs:apigateway:$regionid:$accountid:secretkey/$secretKeyId oracs:apigateway:$regionid:$accountid:trafficcontrol/$trafficcontrolId)
SetDomainacs:apigateway:$regionid:$accountid:apigroup/$groupId
SetDomainCertificateacs:apigateway:$regionid:$accountid:apigroup/$groupId
SwitchApiacs:apigateway:$regionid:$accountid:apigroup/$groupId
CreateSecretKeyacs:apigateway:$regionid:$accountid:secretkey/*
DeleteSecretKeyacs:apigateway:$regionid:$accountid:secretkey/$secretKeyId

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值