AWS 第 4 版簽署程序 (SigV4) 驗證特定的政策索引鍵 - Amazon Simple Storage Service

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

AWS 第 4 版簽署程序 (SigV4) 驗證特定的政策索引鍵

下表顯示與 AWS 第 4 版簽署程序 (SigV4) 身分驗證相關且可搭配 Amazon S3 on Outposts 使用的條件金鑰。在儲存貯體政策中,您可以新增這些條件,以便在使用第 4 版簽署程序來驗證請求時強制執行特定行為。如需取得範例政策,請參閱 使用第 4 版簽署程序相關條件金鑰的儲存貯體政策範例。如需使用 Signature 第 4 版身分驗證請求的詳細資訊,請參閱《Amazon Simple Storage Service API 參考》中的「身分驗證請求 (AWS 第 4 版簽署程序)」

s3-outposts:* 動作或任何 S3 on Outposts 動作的適用金鑰
適用金鑰 Description (描述)

s3-outposts:authType

S3 on Outposts 支援多種不同的身分驗證方法。若要限制傳入請求使用特定身分驗證方法,您可以使用此可選條件金鑰。例如,您可以使用此條件金鑰,僅允許 HTTP Authorization 標頭用在請求身分驗證中。

有效值:

REST-HEADER

REST-QUERY-STRING

s3-outposts:signatureAge

簽章在已驗證請求中有效的時間長度 (以毫秒為單位)。

此條件僅適用於預先簽章 URL。

在第 4 版簽署程序中,簽署金鑰的有效期限最長七天。因此,簽章的有效期限也是最長七天。如需詳細資訊,請參閱《Amazon Simple Storage Service API 參考》中的「簽署請求簡介」。您可以使用此條件來進一步限制簽章存留期。

範例值:600000

s3-outposts:x-amz-content-sha256

您可以使用此條件金鑰以不允許在儲存貯體中未簽署的內容。

當您使用第 4 版簽署程序時,針對使用 Authorization 標頭的請求,會在簽署計算中新增 x-amz-content-sha256 標頭,然後將其值設定為雜湊承載。

您可以在儲存貯體政策中使用此條件金鑰,拒絕任何尚未簽署承載的上傳項目。例如:

  • 拒絕使用了 Authorization 標頭來驗證請求但並未簽署承載的上傳項目。如需詳細資訊,請參閱 Amazon Simple Storage Service API 參考中的在單個區塊中傳輸承載

  • 拒絕使用預先簽章 URL 的上傳。預先簽章 URL 一律有 UNSIGNED_PAYLOAD。如需詳細資訊,請參閱 Amazon Simple Storage Service API 參考中的身分驗證請求身分驗證方法

有效值:UNSIGNED-PAYLOAD

使用第 4 版簽署程序相關條件金鑰的儲存貯體政策範例

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

範例 : 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"} } } ] }
範例 : s3-outposts:authType

下列儲存貯體政策僅允許使用 Authorization 標頭以供請求驗證的任何請求。任何預先簽章 URL 請求都會遭到拒絕,因為預先簽章 URL 會使用查詢參數來提供請求和驗證資訊。如需詳細資訊,請參閱《Amazon Simple Storage Service API 參考》中的「身分驗證方法」。

{ "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" } } } ] }
範例 : s3-outposts:x-amz-content-sha256

下列儲存貯體政策會拒絕任何具有未簽署承載的上傳項目,例如使用預先簽章 URL 的上傳。如需詳細資訊,請參閱 Amazon Simple Storage Service API 參考中的身分驗證請求身分驗證方法

{ "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" } } } ] }