驗證的訪問策略邏輯短路 - AWS 驗證存取

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

驗證的訪問策略邏輯短路

您可能想要寫一個 AWS Verified Access 評估指定前後關聯中可能存在或可能不存在的資料的策略。如果您在不存在的前後關聯中參照資料,Cedar 將產生錯誤並評估原則以拒絕存取,無論您的意圖為何。例如,這將導致拒絕,因為在此上下文中fake_providerbogus_key不存在。

permit(principal, action, resource) when { context.fake_provider.bogus_key > 42 };

為了避免這種情況,您可以使用has運算符檢查是否存在密鑰。如果has運算子傳回 false,則會停止對鏈結陳述式的進一步評估,且 Cedar 不會產生嘗試參照不存在的項目的錯誤。

permit(principal, action, resource) when { context.identity.user has "some_key" && context.identity.user.some_key > 42 };

這在指定參考兩個不同信任提供者的原則時最有用。

permit(principal, action, resource) when { // user is in an allowed group context.aws_idc.groups has "c242c5b0-6081-1845-6fa8-6e0d9513c107" &&( ( // if CrowdStrike data is present, // permit if CrowdStrike's overall assessment is over 50 context has "crowdstrike" && context.crowdstrike.assessment.overall > 50 ) || ( // if Jamf data is present, // permit if Jamf's risk score is acceptable context has "jamf" && ["LOW", "NOT_APPLICABLE", "MEDIUM", "SECURE"].contains(context.jamf.risk) ) ) };