全部產品
Search
文件中心

Tablestore:配置存取權限

更新時間:Jun 25, 2026

知識儲存服務和記憶儲存服務支援通過 RAM Policy,從介面(Action)和資源(Resource)兩個維度對訪問進行精細化控制,授權粒度可精細到知識庫子空間或記憶範圍(scope),滿足多業務、多團隊、多租戶情境下的訪問隔離需求。

適用範圍

本文描述的鑒權規則適用於以下兩類 API。

  • 知識儲存相關 API:管理知識儲存、文檔(Document)、切片(Chunk),以及知識檢索(Retrieve)。

  • 記憶儲存相關 API:管理記憶儲存、記憶(Memory)、記憶訊息與請求、記憶任務(Task)以及 Dream 任務(Dream Task)等。

授權文法和元素

RAM PolicyEffectActionResourceCondition 四個元素組成,通用文法詳見授權文法與元素,本文僅介紹知識儲存與記憶儲存相關的差異部分,即 Action 的取值範圍與 Resource 的資源 ARN 格式。

介面(Action)

Action 格式為 ots:<API 名稱>,支援萬用字元 *,例如 ots:*KnowledgeBase 匹配全部知識儲存管理操作,ots:*Memory* 匹配全部記憶相關操作。下表按功能分組列出全部可授權介面。

知識儲存

功能分組

Action

知識儲存管理

ots:CreateKnowledgeBaseots:DescribeKnowledgeBaseots:UpdateKnowledgeBaseots:ListKnowledgeBaseots:DeleteKnowledgeBase

文件管理

ots:AddDocumentsots:GetDocumentots:ListDocumentsots:UpdateDocumentots:DeleteDocuments

切片管理

ots:ListChunksots:UpdateChunks

檢索

ots:Retrieve

記憶儲存

功能分組

Action

記憶儲存管理

ots:CreateMemoryStoreots:GetMemoryStoreots:UpdateMemoryStoreots:ListMemoryStoresots:DeleteMemoryStore

記憶管理

ots:AddMemoriesots:SearchMemoriesots:ListMemoriesots:GetMemoryots:UpdateMemoryots:DeleteMemory

訊息與請求

ots:ListMemoryStoreMessagesots:ListMemoryStoreRequestsots:ListMemoryStoreScopes

記憶任務

ots:GetMemoryTaskots:ListMemoryTasks

Dream 任務

ots:CreateMemoryDreamTaskots:GetMemoryDreamTaskots:ListMemoryDreamTasksots:CancelMemoryDreamTaskots:ApplyMemoryDreamActionsots:ListMemoryDreamActions

資源(Resource)

所有資源 ARN 均以執行個體為首碼,整體結構如下。

acs:ots:$region:$accountId:instance/$instanceName/<資源路徑>

預留位置

說明

$region

執行個體所在地區 ID,例如 cn-hangzhou。使用 * 表示放開全部地區。

$accountId

資源所屬阿里雲帳號 ID(UID)。使用 * 表示放開全部帳號。

$instanceName

執行個體名稱。使用 * 表示放開執行個體下的全部資源。

<資源路徑>

知識儲存或記憶儲存的資源路徑,按下文規則拼接。

知識儲存

知識儲存資源支援三個授權層級,從粗到細如下。

授權層級

Resource 格式

匹配範圍

執行個體級

acs:ots:$region:$accountId:instance/$instanceName/*

執行個體下的全部知識儲存。ListKnowledgeBase 等不指定具體知識儲存的操作匹配該層級。

知識儲存級

acs:ots:$region:$accountId:instance/$instanceName/knowledgebase/$knowledgeBaseName

指定的單個知識儲存,包含其下全部文檔與切片。

子空間級

acs:ots:$region:$accountId:instance/$instanceName/knowledgebase/$knowledgeBaseName/subspace/$subspace

指定知識儲存下的單個子空間(subspace)。

資源關鍵字 knowledgebasesubspace 為固定值;$knowledgeBaseName$subspace 取自請求中的同名欄位。鑒權層級按以下規則確定:

  • 請求未攜帶 knowledgeBaseName(典型如列舉類操作)時,按執行個體級 .../instance/$instanceName/* 鑒權。

  • 請求攜帶單個 subspace 時按子空間級鑒權;一次請求涉及多個 subspace 時,回退到所屬知識儲存級 .../knowledgebase/$knowledgeBaseName 鑒權。

  • 如需放開某個知識儲存下的全部子空間,使用萬用字元 .../knowledgebase/$knowledgeBaseName/subspace/*,或直接授權到知識儲存級(其覆蓋範圍包含全部子空間)。

記憶儲存

記憶儲存資源支援三個授權層級,從粗到細如下。

授權層級

Resource 格式

匹配範圍

執行個體級

acs:ots:$region:$accountId:instance/$instanceName/*

執行個體下的全部記憶儲存。ListMemoryStores 等不指定具體記憶儲存的操作匹配該層級。

記憶儲存級

acs:ots:$region:$accountId:instance/$instanceName/memorystore/$memoryStoreName/*

指定記憶儲存下的全部記憶。請求未攜帶 scope 時按該層級鑒權。

範圍(scope)級

acs:ots:$region:$accountId:instance/$instanceName/memorystore/$memoryStoreName/appid/$appId/tenantid/$tenantId/agentid/$agentId/runid/$runId

指定記憶儲存下、指定範圍內的記憶。請求攜帶 scope 時按該層級鑒權。

資源關鍵字 memorystoreappidtenantidagentidrunid 為固定值;$memoryStoreName 取自請求中的同名欄位,$appId$tenantId$agentId$runId 取自請求 scope 中的對應欄位。請求未攜帶 memoryStoreName 時,按執行個體級 .../instance/$instanceName/* 鑒權。

範圍(scope)預設值

請求攜帶 scope 但未指定其中某個欄位時,該欄位在鑒權資源中取預設值 __default__。例如請求 scope 僅指定 appId=app_a,鑒權資源拼接為:

acs:ots:$region:$accountId:instance/$instanceName/memorystore/$memoryStoreName/appid/app_a/tenantid/__default__/agentid/__default__/runid/__default__

在 RAM Policy 中放開某些範圍維度時,必須使用萬用字元 *(如 .../agentid/*/runid/*)顯式佔位,不可省略對應層級,否則將匹配到 __default__ 而非全部值。

常見授權情境樣本

以下樣本統一以執行個體名 myinstance 為例,請將樣本中的 $accountId 替換為實際帳號 ID,並按業務實際情況調整地區、知識儲存名、記憶儲存名等預留位置。

唯讀訪問指定知識儲存

以下策略允許對知識儲存 product_docs_kb 進行檢索與查詢,禁止任何寫操作。

{
  "Version": "1",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ots:DescribeKnowledgeBase",
        "ots:GetDocument",
        "ots:ListDocuments",
        "ots:ListChunks",
        "ots:Retrieve"
      ],
      "Resource": [
        "acs:ots:cn-hangzhou:$accountId:instance/myinstance/knowledgebase/product_docs_kb",
        "acs:ots:cn-hangzhou:$accountId:instance/myinstance/knowledgebase/product_docs_kb/subspace/*"
      ]
    }
  ]
}

按子空間隔離知識庫寫入權限

以下策略允許對知識儲存 product_docs_kb 的子空間 team_a 進行文檔與切片的讀寫,其他子空間不受影響。

{
  "Version": "1",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ots:AddDocuments",
        "ots:GetDocument",
        "ots:ListDocuments",
        "ots:UpdateDocument",
        "ots:DeleteDocuments",
        "ots:ListChunks",
        "ots:UpdateChunks",
        "ots:Retrieve"
      ],
      "Resource": "acs:ots:cn-hangzhou:$accountId:instance/myinstance/knowledgebase/product_docs_kb/subspace/team_a"
    }
  ]
}

按應用維度隔離記憶訪問

以下策略允許對記憶儲存 agent_memappId=app_a 的全部記憶(不限 tenant、agent、run)進行讀寫,其他 appId 的記憶不可訪問。

{
  "Version": "1",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ots:AddMemories",
        "ots:SearchMemories",
        "ots:ListMemories",
        "ots:GetMemory",
        "ots:UpdateMemory",
        "ots:DeleteMemory"
      ],
      "Resource": "acs:ots:cn-hangzhou:$accountId:instance/myinstance/memorystore/agent_mem/appid/app_a/tenantid/*/agentid/*/runid/*"
    }
  ]
}

未限定的 tenantidagentidrunid 必須用 * 顯式放開,不可省略,原因見上文範圍(scope)預設值說明。

執行個體內全權管理

以下策略允許對執行個體 myinstance 下所有相關資源執行全部操作。

{
  "Version": "1",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ots:*KnowledgeBase",
        "ots:*Document*",
        "ots:*Chunks",
        "ots:Retrieve",
        "ots:*Memory*"
      ],
      "Resource": "acs:ots:cn-hangzhou:$accountId:instance/myinstance/*"
    }
  ]
}

注意事項

  • 資源首碼始終為執行個體:資源 ARN 必須以 acs:ots:$region:$accountId:instance/$instanceName/ 開頭,知識儲存與記憶儲存均不存在跨執行個體的資源形態。

  • 上級覆蓋下級:上層資源天然覆蓋其下子資源。授權到知識儲存級即覆蓋其下全部子空間,授權到記憶儲存級 memorystore/$store/* 即覆蓋其下全部範圍。需要精細控制時,下鑽到子空間級或範圍級。

  • 主帳號不受策略約束:以上策略僅作用於 RAM 使用者與角色,主帳號(Root)預設擁有自有資源的全部許可權。