方法:delegate
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
這項呼叫會傳回新的驗證 JSON Web Token (JWT),讓實體代表原始驗證 JWT 中通過驗證的使用者,存取指定資源。當其他實體需要代表使用者執行動作時,這個權杖可用於將範圍存取權委派給包裝或解除包裝。
HTTP 要求
POST https://<base_url>/delegate
將 <base_url>
替換為金鑰存取控制清單服務 (KACLS) 網址。
路徑參數
無。
要求主體
要求主體包含要求的 JSON 表示法:
JSON 表示法 |
{
"authentication": string,
"authorization": string,
"reason": string
}
|
欄位 |
authentication |
string
第三方發出的 JWT,用於聲明使用者身分。詳情請參閱驗證一節。
|
authorization |
string
JWT 包含 delegated_to 和 resource_name 憑證附加資訊,可聲明 delegated_to 憑證附加資訊所識別的實體有權代表使用者存取 resource_name 。詳情請參閱「授權權杖」。
|
reason |
string (UTF-8)
這個 JSON 字串會直接傳遞,提供作業的額外背景資訊。顯示前應先清除提供的 JSON。大小上限:1 KB。
|
必要處理步驟
KACLS 至少須執行下列步驟:
- 驗證授權和驗證權杖。詳情請參閱「授權權杖」和「驗證權杖」。
- 確認授權和驗證權杖適用於同一位使用者。
詳情請參閱加密及解密資料。
- 檢查授權權杖中的
kacls_url
聲明是否與目前的 KACLS 網址相符。這樣一來,系統就能偵測內部人員或惡意網域管理員設定的潛在中間人伺服器。
- 如果授權權杖中存在
kacls_owner_domain
聲明,請確認該值與 KACLS 擁有者的 Google Workspace 網域相符。這有助於防止未經授權的使用者向 Google 註冊 KACLS。
- 記錄作業,包括發起作業的使用者、
delegated_to
、resource_name
,以及要求中傳遞的原因。
- 產生、簽署並傳回 JWT 憑證,其中包含授權權杖的
delegated_to
和 resource_name
聲明。
KACLS 可免費執行額外安全檢查,包括以 JWT 宣告為準的檢查。
回應主體
如果成功,這個方法會傳回包含 delegated_to
和 resource_name
聲明的驗證 JWT。這個權杖稍後可用於呼叫 Wrap 和 Unwrap 方法時的驗證。如果發生錯誤,應傳回結構化錯誤回覆。
JSON 表示法 |
{
"delegated_authentication": string
}
|
範例
要求
POST https://mykacls.example.com/v1/delegate
{
"authentication": "eyJhbGciOi...",
"authorization": "eyJhbGciOi...delegated_to\":\"other_entity_id\",\"resource_name\":\"meeting_id\"...}",
"reason": "{client:'meet' op:'delegate_access'}"
}
回應
{
"delegated_authentication": "eyJhbGciOi...delegated_to_from_authz_token...resource_name_from_authz_token...}"
}
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[],[],null,["# Method: delegate\n\nThis call returns a new authentication JSON Web Token (JWT) that allows\nan entity to access a specified resource on behalf of the user\nauthenticated in the original authentication JWT. It is used to delegate\nscoped access to [wrap](/workspace/cse/reference/wrap) or\n[unwrap](/workspace/cse/reference/unwrap) to another entity when that\nentity needs to act on behalf of the user.\n\n### HTTP request\n\n`POST https://\u003cbase_url\u003e/delegate`\n\nReplace `\u003cbase_url\u003e` with the Key Access Control List Service (KACLS) URL.\n\n### Path parameters\n\nNone.\n\n### Request body\n\nThe request body contains a JSON representation of the request:\n\n| JSON representation ||\n|---------------------------------------------------------------------------------|---|\n| ``` { \"authentication\": string, \"authorization\": string, \"reason\": string } ``` |\n\n| Fields ||\n|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `authentication` | `string` A JWT issued by a third-party asserting who the user is. See the authentication section for details. |\n| `authorization` | `string` A JWT with `delegated_to` and `resource_name` claims asserting that the entity identified by `delegated_to` claim is allowed to access `resource_name` on behalf of the user. For more information, see [Authorization Tokens](/workspace/cse/reference/authorization-tokens). |\n| `reason` | `string (UTF-8)` A passthrough JSON string providing additional context about the operation. The JSON provided should be sanitized before being displayed. Max size: 1 KB. |\n\n### Required processing steps\n\nThe KACLS must perform at least these steps:\n\n- Validate both authorization and authentication tokens. For more information, see [Authorization Tokens](/workspace/cse/reference/authorization-tokens) and [Authentication Tokens](/workspace/cse/reference/authentication-tokens).\n- Check that authorization and authentication tokens are for the same user. For more information, see [Encrypt and decrypt data](/workspace/cse/guides/encrypt-and-decrypt-data).\n- Check that the `kacls_url` claim in the authorization token matches the current KACLS URL. This allows detection of potential man-in-the-middle servers configured by insiders or rogue domain admins.\n- If the `kacls_owner_domain` claim exists in the authorization token, check that the value matches the KACLS owner's Google Workspace domain. This helps prevent unauthorized users from registering your KACLS with Google.\n- Log the operation, including the user originating it, the `delegated_to`, the `resource_name`, and the reason passed in the request.\n- Generate, sign, and return a JWT token containing `delegated_to` and `resource_name` claims from the authorization token.\n\nThe KACLS is free to perform additional security checks, including JWT claim\nbased ones.\n\n### Response body\n\nIf successful, this method returns an authentication JWT containing\n`delegated_to` and `resource_name` claims. This token can later be used for\nauthentication in calls to the Wrap and Unwrap methods. In case of an error, a\n[structured error reply](/workspace/cse/reference/structured-errors)\nshould be returned.\n\n| JSON representation ||\n|------------------------------------------------|---|\n| ``` { \"delegated_authentication\": string } ``` |\n\n| Fields ||\n|----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `delegated_authentication` | `string` A delegated authentication JWT valid for accessing `resource_name` by the user mentioned in the original authentication JWT. For more information, see [KACLS authentication token for `delegate`](/workspace/cse/reference/authentication-tokens#kacls_authentication_token_for_delegate). |\n\n### Example\n\n#### Request\n\n POST https://mykacls.example.com/v1/delegate\n {\n \"authentication\": \"eyJhbGciOi...\",\n \"authorization\": \"eyJhbGciOi...delegated_to\\\":\\\"other_entity_id\\\",\\\"resource_name\\\":\\\"meeting_id\\\"...}\",\n \"reason\": \"{client:'meet' op:'delegate_access'}\"\n }\n\n#### Response\n\n {\n \"delegated_authentication\": \"eyJhbGciOi...delegated_to_from_authz_token...resource_name_from_authz_token...}\"\n }"]]