

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

# Verified Access 政策陳述式結構
<a name="auth-policies-policy-statement-struct"></a>

下表顯示 Verified Access 政策的結構。


| 元件 | 語法 | 
| --- | --- | 
| 效用 | `permit \| forbid` | 
| scope | `(principal, action, resource)` | 
| 條件子句 | <pre>when {<br />    context.{{policy-reference-name}}.{{attribute-name}}             <br />};</pre>  | 

## 政策元件
<a name="auth-policies-policy-components"></a>

Verified Access 政策包含下列元件：
+ **效果** – `permit`（允許） 或 `forbid`（拒絕） 存取。
+ **範圍** – 套用效果的主體、動作和資源。您可以讓 Cedar 中的範圍保持未定義，方法是無法識別特定委託人、動作或資源。在此情況下，政策適用於所有可能的委託人、動作和資源。
+ **條件子句** – 套用效果的內容。

**重要**  
對於 Verified Access，政策是透過參考條件子句中的信任資料來完全表示。**政策範圍必須一律保持未定義**。然後，您可以使用 條件子句中的身分和裝置信任內容來指定存取權。

## 說明
<a name="auth-policies-policy-comments"></a>

您可以在 AWS Verified Access 政策中包含註解。註解定義為以換行字元開頭`//`和結尾的行。

下列範例顯示政策中的註解。

```
// grants access to users in a specific domain using trusted devices
permit(principal, action, resource)
when {
  // the user's email address is in the @example.com domain
  context.idc.user.email.address.contains("@example.com")
  // Jamf thinks the user's computer is low risk or secure.
  && ["LOW", "SECURE"].contains(context.jamf.risk)
};
```

## 多個子句
<a name="auth-policies-multiple-clauses"></a>

您可以使用 `&&`運算子在政策陳述式中使用多個條件子句。

```
permit(principal,action,resource)
when{
 context.{{policy-reference-name}}.{{attribute1}} &&
 context.{{policy-reference-name}}.{{attribute2}}
};
```

如需額外的範例，請參閱[驗證存取範例政策](trust-data-iam-add-pol.md)。

## 預留字元
<a name="auth-policies-semicolon"></a>

下列範例示範如何在內容屬性使用 `:`（分號） 時撰寫政策，這是政策語言的預留字元。

```
permit(principal, action, resource) 
when {
    context.{{policy-reference-name}}["namespace:groups"].contains("finance")
};
```