

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

# 驗證存取範例政策
<a name="trust-data-iam-add-pol"></a>

您可以使用 Verified Access 政策，將應用程式存取權授予特定使用者和裝置。

**Topics**
+ [範例 1：將存取權授予 IAM Identity Center 中的群組](#example-policy-iam-identity-center)
+ [範例 2：將存取權授予第三方供應商中的群組](#example-policy-oidc-provider)
+ [範例 3：使用 CrowdStrike 授予存取權](#example-policy-crowdstrike)
+ [範例 4：允許或拒絕特定 IP 地址](#example-policy-ip-address)

## 範例 1：將存取權授予 IAM Identity Center 中的群組
<a name="example-policy-iam-identity-center"></a>

使用 時 AWS IAM Identity Center，最好使用群組IDs 來參考群組。如果您變更群組的名稱，這有助於避免中斷政策陳述式。

下列範例政策僅允許具有已驗證電子郵件地址之指定群組中的使用者存取 。群組 ID 為 c242c5b0-6081-1845-6fa8-6e0d9513c107。

```
permit(principal,action,resource)
when {
    context.{{policy-reference-name}}.groups has "{{c242c5b0-6081-1845-6fa8-6e0d9513c107}}"
    && context.{{policy-reference-name}}.user.email.verified == true
};
```

下列範例政策僅在使用者位於指定群組、使用者具有已驗證的電子郵件地址，且 Jamf 裝置風險分數為 時，才允許存取`LOW`。

```
permit(principal,action,resource)
when {
    context.{{policy-reference-name}}.groups has "{{c242c5b0-6081-1845-6fa8-6e0d9513c107}}"
    && context.{{policy-reference-name}}.user.email.verified == true
    && context.jamf.risk == "LOW"
};
```

如需信任資料的詳細資訊，請參閱 [AWS IAM Identity Center Verified Access 信任資料的內容](trust-data-iam.md)。

## 範例 2：將存取權授予第三方供應商中的群組
<a name="example-policy-oidc-provider"></a>

下列範例政策僅在使用者位於指定群組、使用者具有已驗證的電子郵件地址，且 Jamf 裝置風險分數為 LOW 時，才允許存取。群組的名稱為「財務」。

```
permit(principal,action,resource)
when {
     context.{{policy-reference-name}}.groups.contains("{{finance}}") 
     && context.{{policy-reference-name}}.email_verified == true
     && context.jamf.risk == "LOW"
};
```

如需信任資料的詳細資訊，請參閱 [Verified Access 信任資料的第三方信任提供者內容](trust-data-third-party-trust.md)。

## 範例 3：使用 CrowdStrike 授予存取權
<a name="example-policy-crowdstrike"></a>

下列範例政策允許在整體評估分數大於 50 時存取 。

```
permit(principal,action,resource)
when {
    context.crwd.assessment.overall > 50 
};
```

## 範例 4：允許或拒絕特定 IP 地址
<a name="example-policy-ip-address"></a>

下列範例政策允許來自指定 IP 地址的 HTTP 請求。

```
permit(principal, action, resource) 
when {
    context.http_request.client_ip == "{{192.0.2.1}}"
};
```

下列範例政策拒絕來自指定 IP 地址的 HTTP 請求。

```
forbid(principal,action,resource) 
when { 
    ip(context.http_request.client_ip).isInRange(ip("{{192.0.2.1/32}}")) 
};
```

下列範例政策允許來自指定 IP 地址的 TCP 請求。

```
permit(principal, action, resource) 
when {
    context.tcp_flow.client_ip == "{{192.0.2.1}}"
};
```