

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 예제 2: Verified Permissions 및 Cedar가 포함된 기본 RBAC
<a name="avp-basic-rbac-examples"></a>

이 예제에서는 Verified Permissions 및 Cedar를 사용하여 기본 RBAC를 보여줍니다. 앞서 언급했듯이 Cedar의 기본 구성은 개체입니다. 개발자는 자체 엔터티를 정의하고 선택적으로 엔터티 간에 관계를 생성할 수 있습니다. 다음 예제에는 `Users`, `Roles`,의 세 가지 유형의 엔터티가 포함됩니다`Problems`. `Students` 및는 유형의 엔터티로 간주될 `Teachers` 수 `Role,` 있으며 각는 0 또는 임의의와 연결될 `User` 수 있습니다`Roles`.

![PDP를 구현하기 위한 Amazon Verified Permissions 및 Cedar를 사용한 기본 RBAC 구현의 예](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/saas-multitenant-api-access-authorization/images/avp-example-2.png)


Cedar에서 이러한 관계는를 상위`Role``Student``User``Bob`로에 연결하여 표현됩니다. 이 연결은 한 그룹의 모든 학생 사용자를 논리적으로 그룹화합니다. Cedar의 그룹화에 대한 자세한 내용은 [Cedar 설명서를](https://docs.cedarpolicy.com/overview/terminology.html#term-group) 참조하세요.

다음 정책은 유형의 논리적 그룹에 연결된 모든 보안 주체`ALLOW`에 `submitProblem,` 대한 작업 결정에 따라 평가`Students`됩니다`Role`.

```
permit (
    principal in ElearningApp::Role::"Students",
    action == ElearningApp::Action::"submitProblem",
    resource
);
```

다음 정책은 유형의 논리적 그룹에 연결된 모든 보안 주체에 `ALLOW` 대해 작업 `submitProblem` 또는 `Teachers`에 `answerProblem`대한 결정으로 평가됩니다`Role`.

```
permit (
    principal in ElearningApp::Role::"Teachers",
    action in [
        ElearningApp::Action::"submitProblem",
        ElearningApp::Action::"answerProblem"
    ],
    resource
);
```

이러한 정책을 사용하여 요청을 평가하려면 평가 엔진이 권한 부여 요청 내에서 참조되는 보안 주체가 적절한 그룹의 구성원인지 여부를 알아야 합니다. 따라서 애플리케이션은 권한 부여 요청의 일부로 평가 엔진에 관련 그룹 멤버십 정보를 전달해야 합니다. 이는 `entities` 권한 부여 호출과 관련된 보안 주체 및 리소스에 대한 속성 및 그룹 멤버십 데이터를 Cedar 평가 엔진에 제공할 수 있는 속성을 통해 수행됩니다. 다음 코드에서 그룹 멤버십은 라는 상위를 갖는 `User::"Bob"` 것으로 정의하여 표시됩니다`Role::"Students"`.

```
{
  "policyStoreId": "ELEARNING_POLICYSTOREID",
  "principal": {
    "entityType": "ElearningApp::User",
    "entityId": "Bob"
  },
  "action": {
    "actionType": "ElearningApp::Action",
    "actionId": "answerProblem"
  },
  "resource": {
    "entityType": "ElearningApp::Problem",
    "entityId": "SomeProblem"
  },
  "entities": {
    "entityList": [
        {
            "identifier": {
                "entityType": "ElearningApp::User",
                "entityId": "Bob"
            },
            "attributes": {},
            "parents": [
                {
                    "entityType": "ElearningApp::Role",
                    "entityId": "Students"
                } 
            ]
        },
        {
          "identifier": {
            "entityType": "ElearningApp::Problem",
            "entityId": "SomeProblem"
          },
          "attributes": {},
          "parents": []
        }
      ]
  }
}
```

이 예제에서 Bob은 `answerProblem` 요청을 하는 로그인한 사용자입니다. 따라서 Bob은 보안 주체이고 개체는 유형입니다`User`. Bob이 수행하려고 하는 작업은 입니다`answerProblem`. Bob이 `answerProblem` 작업을 수행할 수 있는지 평가하려면 상위 엔터티를 로 나열하여 엔터티`User`를 값과 연결하고 그룹 멤버십을 `Bob` 할당하는 엔터티 구조를 제공해야 합니다`Role::"Students"`. 사용자 그룹의 엔터티`Role::"Students"`는 작업 만 수행할 수 있으므로 `submitProblem`이 권한 부여 요청은 로 평가됩니다`DENY`.

반면, `User` 값이 `Alice` 이고 그룹의 일부인 유형이 `answerProblem` 작업을 수행`Role::"Teachers"` 하려고 하면 권한 부여 요청은 로 평가됩니다. 정책에 따라 그룹의 보안 주체가 `answerProblem` 모든 리소스에서 작업을 수행할 `Role::"Teachers"` 수 있다고 명시되어 있기 `ALLOW`때문입니다. 다음 코드는가 로 평가하는 이러한 유형의  권한 부여 요청을 보여줍니다`ALLOW`.

```
{
  "policyStoreId": "ELEARNING_POLICYSTOREID",
  "principal": {
    "entityType": "ElearningApp::User",
    "entityId": "Alice"
  },
  "action": {
    "actionType": "ElearningApp::Action",
    "actionId": "answerProblem"
  },
  "resource": {
    "entityType": "ElearningApp::Problem",
    "entityId": "SomeProblem"
  },
  "entities": {
    "entityList": [
        {
            "identifier": {
                "entityType": "ElearningApp::User",
                "entityId": "Alice"
            },
            "attributes": {},
            "parents": [
                {
                    "entityType": "ElearningApp::Role",
                    "entityId": "Teachers"
                } 
            ]
        },
        {
            "identifier": {
                "entityType": "ElearningApp::Problem",
                "entityId": "SomeProblem"
            },
            "attributes": {},
            "parents": []
        }
      ]
  }
}
```