更新时间:2024-04-08 GMT+08:00

消息通知服务 SMN

Organizations服务中的服务控制策略(Service Control Policy,以下简称SCP)可以使用以下授权项元素设置访问控制策略。

SCP不直接进行授权,只划定权限边界。将SCP绑定到组织单元或者成员账号时,并没有直接对组织单元或成员账号授予操作权限,而是规定了成员账号或组织单元包含的成员账号的授权范围。

本章节介绍组织服务中SCP使用的元素,这些元素包含了操作(Action)、资源(Resource)和条件(Condition)。

如何使用这些元素编辑SCP自定义策略,请参考创建SCP

操作(Action)

操作(Action)即为SCP中支持的授权项。

  • “访问级别”列描述如何对操作进行分类(list、read和write等)。此分类可帮助您了解在SCP中相应操作对应的访问级别。
  • “资源类型”列指每个操作是否支持资源级权限。
    • 资源类型支持通配符号*表示所有。如果此列没有值(-),则必须在SCP语句的Resource元素中指定所有资源类型(“*”)。
    • 如果该列包含资源类型,则必须在具有该操作的语句中指定该资源的URN。
    • 资源类型列中必需资源在表中用星号(*)标识,表示使用此操作必须指定该资源类型。

    关于SMN定义的资源类型的详细信息请参见资源类型(Resource)

  • “条件键”列包括了可以在SCP语句的Condition元素中支持指定的键值。
    • 如果该授权项资源类型列存在值,则表示条件键仅对列举的资源类型生效。
    • 如果该授权项资源类型列没有值(-),则表示条件键对整个授权项生效。
    • 如果此列没有值(-),表示此操作不支持指定条件键。

    关于SMN定义的条件键的详细信息请参见条件(Condition)

您可以在SCP语句的Action元素中指定以下SMN的相关操作。

表1 SMN支持的授权项

授权项

描述

访问级别

资源类型(*为必须)

条件键

smn:topic:create

授予创建主题的权限。

write

topic *

-

-

  • g:EnterpriseProjectId
  • g:RequestTag/<tag-key>
  • g:TagKeys

smn:topic:listTopic

授予查询主题列表的权限。

list

topic *

-

-

g:EnterpriseProjectId

smn:topic:updateTopic

授予更新主题信息的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

smn:topic:get

授予查询主题详情的权限。

read

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

smn:topic:delete

授予删除主题的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

smn:topic:listAttributes

授予查询主题策略的权限。

list

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

smn:topic:deleteAttribute

授予删除主题策略的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

smn:topic:updateAttribute

授予更新主题策略的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

-

  • smn:TargetOrgPath
  • smn:TargetOrgId
  • smn:TargetAccountId

smn:topic:subscribe

授予主题下创建订阅的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

-

  • smn:Protocol
  • smn:Endpoint

smn:topic:listSubscriptionsByTopic

授予查询指定主题的订阅列表的权限。

list

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

smn:topic:listSubscriptions

授予查询所有主题的订阅列表的权限。

list

topic *

-

smn:topic:deleteSubscription

授予删除指定主题下的订阅的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

smn:topic:updateSubscription

授予更新指定主题下的订阅的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

smn:topic:publish

授予发送消息的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

smn:template:create

授予创建模板的权限。

write

template *

-

smn:template:listTemplates

授予查询模板列表的权限。

list

template *

-

smn:template:update

授予修改模板的权限。

write

template *

-

smn:template:get

授予查询模板详情的权限。

read

template *

-

smn:template:delete

授予删除模板的权限。

write

template *

-

smn:tag:create

授予指定主题创建标签的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

-

  • g:RequestTag/<tag-key>
  • g:TagKeys

smn:tag:delete

授予删除主题标签的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

-

  • g:RequestTag/<tag-key>
  • g:TagKeys

smn:tag:batchModify

授予批量修改主题标签的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

-

  • g:RequestTag/<tag-key>
  • g:TagKeys

smn:tag:list

授予查询主题标签的权限。

read

topic *

g:ResourceTag/<tag-key>

smn:topic:createLogTank

授予为主题关联日志组和日志流的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

smn:topic:listLogTank

授予查询主题的日志组和日志流的权限。

list

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

smn:topic:updateLogTank

授予更新主题的日志组和日志流的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

smn:topic:deleteLogTank

授予解除主题的日志组和日志流关系的权限。

write

topic *

  • g:EnterpriseProjectId
  • g:ResourceTag/<tag-key>

SMN的API通常对应着一个或多个授权项。表2展示了API与授权项的关系,以及该API需要依赖的授权项。

表2 API与授权项的关系

API

对应的授权项

依赖的授权项

POST /v2/{project_id}/notifications/topics

smn:topic:create

-

GET /v2/{project_id}/notifications/topics

smn:topic:listTopic

-

PUT /v2/{project_id}/notifications/topics/{topic_urn}

smn:topic:updateTopic

-

GET /v2/{project_id}/notifications/topics/{topic_urn}

smn:topic:get

-

DELETE /v2/{project_id}/notifications/topics/{topic_urn}

smn:topic:delete

-

GET /v2/{project_id}/notifications/topics/{topic_urn}/attributes

smn:topic:listAttributes

-

DELETE /v2/{project_id}/notifications/topics/{topic_urn}/attributes

smn:topic:deleteAttribute

-

PUT /v2/{project_id}/notifications/topics/{topic_urn}/attributes/{name}

smn:topic:updateAttribute

-

DELETE /v2/{project_id}/notifications/topics/{topic_urn}/attributes/{name}

smn:topic:deleteAttribute

-

POST /v2/{project_id}/notifications/topics/{topic_urn}/subscriptions

smn:topic:subscribe

-

GET /v2/{project_id}/notifications/topics/{topic_urn}/subscriptions

smn:topic:listSubscriptionsByTopic

-

PUT /v2/{project_id}/notifications/topics/{topic_urn}/subscriptions/{subscription_urn}

smn:topic:updateSubscription

-

DELETE /v2/{project_id}/notifications/subscriptions/{subscription_urn}

smn:topic:deleteSubscription

-

GET /v2/{project_id}/notifications/subscriptions

smn:topic:listSubscriptions

-

POST /v2/{project_id}/notifications/topics/{topic_urn}/publish

smn:topic:publish

-

POST /v2/{project_id}/notifications/message_template

smn:template:create

-

GET /v2/{project_id}/notifications/message_template

smn:template:listTemplates

-

PUT /v2/{project_id}/notifications/message_template/{message_template_id}

smn:template:update

-

GET /v2/{project_id}/notifications/message_template/{message_template_id}

smn:template:get

-

DELETE /v2/{project_id}/notifications/message_template/{message_template_id}

smn:template:delete

-

POST /v2/{project_id}/{resource_type}/{resource_id}/tags

smn:tag:create

-

GET /v2/{project_id}/{resource_type}/{resource_id}/tags

smn:tag:list

-

POST /v2/{project_id}/{resource_type}/{resource_id}/tags/action

smn:tag:batchModify

  • smn:tag:create
  • smn:tag:delete

DELETE /v2/{project_id}/{resource_type}/{resource_id}/tags/{key}

smn:tag:delete

-

GET /v2/{project_id}/{resource_type}/tags

smn:tag:list

-

POST /v2/{project_id}/{resource_type}/resource_instances/action

smn:tag:list

-

GET /v2/{project_id}/notifications/topics/{topic_urn}/logtanks

smn:topic:listLogTank

-

POST /v2/{project_id}/notifications/topics/{topic_urn}/logtanks

smn:topic:createLogTank

-

PUT /v2/{project_id}/notifications/topics/{topic_urn}/logtanks/{logtank_id}

smn:topic:updateLogTank

-

DELETE /v2/{project_id}/notifications/topics/{topic_urn}/logtanks/{logtank_id}

smn:topic:deleteLogTank

-

POST /v2/{project_id}/notifications/subscriptions/filter_polices

smn:topic:updateSubscription

-

PUT /v2/{project_id}/notifications/subscriptions/filter_polices

smn:topic:updateSubscription

-

DELETE /v2/{project_id}/notifications/subscriptions/filter_polices

smn:topic:updateSubscription

-

POST /v2/{project_id}/notifications/topics/{topic_urn}/subscriptions/from-subscription-users

smn:topic:subscribe

-

资源类型(Resource)

资源类型(Resource)表示SCP所作用的资源。如表3中的某些操作指定了可以在该操作指定的资源类型,则必须在具有该操作的SCP语句中指定该资源的URN,SCP仅作用于此资源;如未指定,Resource默认为“*”,则SCP将应用到所有资源。您也可以在SCP中设置条件,从而指定资源类型。

SMN定义了以下可以在SCP的Resource元素中使用的资源类型。

表3 SMN支持的资源类型

资源类型

URN

topic

smn:<region>:<account-id>:topic:<topic-id>

template

smn:<region>:<account-id>:template:<template-id>

条件(Condition)

条件(Condition)是SCP生效的特定条件,包括条件键运算符

  • 条件键表示SCP语句的Condition元素中的键值。根据适用范围,分为全局级条件键和服务级条件键。
    • 全局级条件键(前缀为g:)适用于所有操作,在鉴权过程中,云服务不需要提供用户身份信息,系统将自动获取并鉴权。详情请参见:全局条件键
    • 服务级条件键(前缀为服务缩写,如smn:)仅适用于对应服务的操作,详情请参见表4
    • 单值/多值表示API调用时请求中与条件关联的值数。单值条件键在API调用时的请求中最多包含一个值,多值条件键在API调用时请求可以包含多个值。例如:g:SourceVpce是单值条件键,表示仅允许通过某个VPC终端节点发起请求访问某资源,一个请求最多包含一个VPC终端节点ID值。g:TagKeys是多值条件键,表示请求中携带的所有标签的key组成的列表,当用户在调用API请求时传入标签可以传入多个值。
  • 运算符与条件键、条件值一起构成完整的条件判断语句,当请求信息满足该条件时,SCP才能生效。支持的运算符请参见:运算符

SMN定义了以下可以在SCP的Condition元素中使用的条件键,您可以使用这些条件键进一步细化SCP语句应用的条件。

表4 SMN支持的服务级条件键

服务级条件键

类型

单值/多值

说明

smn:TargetOrgPath

string

单值

主题策略授权的组织路径。

smn:TargetOrgId

string

单值

主题策略授权的组织ID。

smn:TargetAccountId

string

单值

主题策略授权的账号ID。

smn:Protocol

string

单值

订阅终端协议。

smn:Endpoint

string

单值

订阅终端地址。