

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# AWS Signature 第 4 版 (SigV4) 身分驗證特定政策金鑰
<a name="s3-outposts-bucket-policy-s3-sigv4-conditions"></a>

下表顯示與 AWS Signature 第 4 版 (SigV4) 身分驗證相關的條件金鑰，您可以搭配 Amazon S3 on Outposts 使用。在儲存貯體政策中，您可以新增這些條件，以便在使用第 4 版簽署程序來驗證請求時強制執行特定行為。如需範例政策，請參閱 [使用第 4 版簽署程序相關條件金鑰的儲存貯體政策範例](#s3-outposts-bucket-policy-sig-v4-condition-key-example)。如需使用 Signature 第 4 版驗證請求的詳細資訊，請參閱《*Amazon Simple Storage Service API 參考*》中的[驗證請求 (AWS Signature 第 4 版）](https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html) 


| 適用金鑰 | Description | 
| --- | --- | 
|  `s3-outposts:authType`  |  S3 on Outposts 支援多種不同的身分驗證方法。若要限制傳入請求使用特定身分驗證方法，您可以使用此可選條件金鑰。例如，您可以使用此條件金鑰，僅允許 HTTP `Authorization` 標頭用在請求身分驗證中。 有效值： `REST-HEADER`  `REST-QUERY-STRING`   | 
|  `s3-outposts:signatureAge`  |  簽章在已驗證請求中有效的時間長度 (以毫秒為單位)。 此條件僅適用於預先簽章 URL。 在 第 4 版簽署程序中，簽署金鑰的有效期限最長七天。因此，簽章的有效期限也是最長七天。如需詳細資訊，請參閱《*Amazon Simple Storage Service API 參考*》中的「[簽署請求簡介](https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html#signing-request-intro)」。您可以使用此條件來進一步限制簽章存留期。 範例值：`600000`  | 
|  `s3-outposts:x-amz-content-sha256`  |  您可以使用此條件金鑰以不允許在儲存貯體中未簽署的內容。 當您使用第 4 版簽署程序時，針對使用 `Authorization` 標頭的請求，會在簽署計算中新增 `x-amz-content-sha256` 標頭，然後將其值設定為雜湊承載。 您可以在儲存貯體政策中使用此條件金鑰，拒絕任何尚未簽署承載的上傳項目。例如： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AmazonS3/latest/s3-outposts/s3-outposts-bucket-policy-s3-sigv4-conditions.html) 有效值：`UNSIGNED-PAYLOAD`  | 

## 使用第 4 版簽署程序相關條件金鑰的儲存貯體政策範例
<a name="s3-outposts-bucket-policy-sig-v4-condition-key-example"></a>

若要使用下列範例，請以您自己的資訊取代 *`user input placeholders`*。

**Example : `s3-outposts:signatureAge`**  
下列儲存貯體政策會拒絕 `example-outpost-bucket` 中物件上的任何 S3 on Outposts 預先簽章 URL 請求 (如果簽章已超過 10 分鐘之久)。    
****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "Deny a presigned URL request if the signature is more than 10 minutes old",
            "Effect": "Deny",
            "Principal": {"AWS":"444455556666"},
            "Action": "s3-outposts:*",
            "Resource": "arn:aws:s3-outposts:us-east-1:111122223333:outpost/op-01ac5d28a6a232904/bucket/example-outpost-bucket/object/*",
            "Condition": {
                "NumericGreaterThan": {"s3-outposts:signatureAge": 600000},
                "StringEquals": {"s3-outposts:authType": "REST-QUERY-STRING"}
            }
        }
    ]
}
```

**Example : `s3-outposts:authType`**  
下列儲存貯體政策僅允許使用 `Authorization` 標頭以供請求驗證的任何請求。任何預先簽章 URL 請求都會遭到拒絕，因為預先簽章 URL 會使用查詢參數來提供請求和驗證資訊。如需詳細資訊，請參閱《*Amazon Simple Storage Service API 參考*》中的「[身分驗證方法](https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html)」。    
****  

```
{
   "Version":"2012-10-17",		 	 	 
   "Statement": [
         {
               "Sid": "Allow only requests that use the Authorization header for request authentication. Deny presigned URL requests.",
               "Effect": "Deny",
               "Principal": {"AWS":"111122223333"},
               "Action": "s3-outposts:*",
               "Resource": "arn:aws:s3-outposts:us-east-1:111122223333:outpost/op-01ac5d28a6a232904/bucket/example-outpost-bucket/object/*",
               "Condition": {
                     "StringNotEquals": {
                           "s3-outposts:authType": "REST-HEADER"
                     }
               }
         }
   ]
}
```

**Example : `s3-outposts:x-amz-content-sha256`**  
下列儲存貯體政策會拒絕任何具有未簽署承載的上傳項目，例如使用預先簽章 URL 的上傳。如需詳細資訊，請參閱 *Amazon Simple Storage Service API 參考*中的[身分驗證請求](https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html#query-string-auth-v4-signing)和[身分驗證方法](https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html)。    
****  

```
{
   "Version":"2012-10-17",		 	 	 
   "Statement": [
         {
               "Sid": "Deny uploads with unsigned payloads.",
               "Effect": "Deny",
               "Principal": {"AWS":"111122223333"},
               "Action": "s3-outposts:*",
               "Resource": "arn:aws:s3-outposts:us-east-1:111122223333:outpost/op-01ac5d28a6a232904/bucket/example-outpost-bucket/object/*",
               "Condition": {
                     "StringEquals": {
                           "s3-outposts:x-amz-content-sha256": "UNSIGNED-PAYLOAD"
                     }
               }
         }
   ]
}
```