> For the complete documentation index, see [llms.txt](https://docs.panther.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.panther.com/ko/panther/api/graphql/user-management.md).

# 사용자 및 역할 관리

## 개요

Panther API는 다음 사용자 및 역할 작업을 지원합니다:

* 사용자 목록
* ID 또는 이메일 주소로 사용자 가져오기
* 새 사용자 초대
* 사용자 정보 및 역할 업데이트
* 사용자 삭제
* 역할 목록
* ID 또는 이름으로 역할 가져오기
* 새 역할 생성
* 역할 정보 및 권한 업데이트
* 역할 삭제

Console의 API Playground 또는 GraphQL-over-HTTP API를 사용하여 Panther의 API를 호출할 수 있습니다. 이러한 방법에 대해 더 알아보려면 다음을 참조하세요: [Panther API](/ko/panther/api.md#step-1-choose-a-method-for-invoking-the-api).

핵심 사용자 및 역할 관리 작업에 대한 GraphQL 쿼리, 변이, 엔드투엔드 워크플로 예시는 아래 섹션을 참조하세요.

## 일반적인 사용자 및 역할 관리 작업

다음은 Panther에서 가장 일반적인 GraphQL 사용자 및 역할 관리 작업 중 일부입니다. 이 예시는 GraphQL 클라이언트로 보내야 하는 문서를 보여줍니다(또는 `curl`)를 사용해 Panther의 GraphQL API를 호출하기 위해 전송해야 하는 문서를 보여줍니다.

참고: `createdAt` 필드는 ISO 8601 날짜 및 시간 표준 형식입니다.

#### 사용자 목록 보기

```graphql
query users {
  users {
    id
    givenName
    familyName
    email
    상태
    createdAt
    lastLoggedInAt
    role {
      이름
      id
      권한
    }
  }
}
```

#### 사용자 가져오기

{% tabs %}
{% tab title="이메일 주소로 사용자" %}

```graphql
query user {
  userByEmail(email: "example@domain.com") {
    id
    givenName
    familyName
    email
    role {
      이름
      id
      권한
    }
    상태
    createdAt
  }
}
```

{% endtab %}

{% tab title="ID로 사용자" %}

```graphql
query user {
  userById(id: "8h81hfh-ij828db") {
    id
    givenName
    familyName
    email
    role {
      이름
      id
      권한
    }
    상태
    createdAt
  }
}
```

{% endtab %}
{% endtabs %}

#### 새 사용자 초대하기

```graphql
mutation inviteUser {
    inviteUser(input: {
        email: "example@domain.com"
        givenName: "firstname"
        familyName: "lastname"
        role: {
            kind: NAME
            value: "Analyst"
        }
    })
    {
        user {
            id
            상태
        }
    }
  }
```

#### 사용자 업데이트

```graphql
mutation updateUser {
    updateUser(input: {
        id: "8h81hfh-ij828db"
        familyName: "newName"
    })
    {
        user {
            email
            givenName
            familyName
        }
    }
}
```

#### 사용자 삭제하기

```graphql
mutation deleteUser{
  deleteUser(input: {
    id: "8h81hfh-ij828db"
  })
  {
    id # 삭제 작업은 `user` 객체를 반환하지 않습니다. ID만 반환합니다.
  }
}
```

#### 역할 목록 보기

```graphql
query roles {
  roles( 
    # 이 입력은 선택 사항입니다. 입력이 없으면 쿼리는 모든 역할을 반환합니다.
    input: {
      nameContains: "admin",
      sortDir: ascending
    }) 
  {
    createdAt
    id
    이름
    권한
    updatedAt
    updatedBy {
      ... on User {
        email
        id
      }
      ... on APIToken {
        id
        이름
      }
    }
    # 로그 유형별 RBAC가 활성화된 경우에만 사용됨
    logTypeAccess 
    logTypeAccessKind
  }
}
```

#### 역할 가져오기

{% tabs %}
{% tab title="이름으로 역할" %}

```graphql
query adminRole {
  roleByName(
   name: "admin"
   ) {
    createdAt
    id
    이름
    권한
    updatedAt
    updatedBy {
      ... on User {
        email
        id
      }
      ... on APIToken {
        id
        이름
      }
    }
    # 로그 유형별 RBAC가 활성화된 경우에만 사용됨
    logTypeAccess 
    logTypeAccessKind
  }
}
```

{% endtab %}

{% tab title="ID로 역할" %}

```graphql
query adminRole {
  roleById(
   id: "feeafade-c545"
   ) {
    createdAt
    id
    logTypeAccess
    logTypeAccessKind
    이름
    권한
    updatedAt
    updatedBy {
      ... on User {
        email
        id
      }
      ... on APIToken {
        id
        이름
      }
    }
    # 로그 유형별 RBAC가 활성화된 경우에만 사용됨
    logTypeAccess 
    logTypeAccessKind
  }
}
```

{% endtab %}
{% endtabs %}

#### 새 역할 생성하기

{% hint style="warning" %}
**참고:** 권한 `UserModify` 는 Panther 플랫폼에 대한 전체 관리자 접근 권한을 제공합니다. 새 역할에 이 권한을 할당할 때는 주의해서 사용하세요.
{% endhint %}

{% tabs %}
{% tab title="기본" %}

```graphql
mutation createRole {
  createRole(input: {
    name: "new-role"
    permissions: [
      UserRead
      AlertRead
    ]
  })
  {  
    role {
      이름
      id
      권한
    }
  }
}
```

{% endtab %}

{% tab title="로그 유형별 RBAC 활성화됨" %}

```graphql
mutation createRole {
  createRole(input: {
    name: "new-role"
    permissions: [
      UserRead
      AlertRead
    ]
    # 로그 유형별 RBAC 기능이 활성화된 경우에만 사용됨
    logTypeAccess:["AWS.ALB"]
    logTypeAccessKind: ALLOW
  })
  {  
    role {
      이름
      id
      권한
      logTypeAccess
      logTypeAccessKind
    }
  }
}
```

{% endtab %}
{% endtabs %}

#### 역할 업데이트하기

{% hint style="warning" %}
**참고:** updateRole 입력의 권한은 **모든** 역할에 대한 원하는 권한을 포함해야 합니다.
{% endhint %}

{% tabs %}
{% tab title="기본" %}

```graphql
mutation updateRole {
  updateRole(input: {
    id: "fea8sje-92jdnhc"
    name: "updated-role-name"
    permissions: [
      UserRead
      AlertRead
      AlertModify
    ]
  })
  {
    role {
      이름
      id
      권한
    }
  }
}
```

{% endtab %}

{% tab title="로그 유형별 RBAC 활성화됨" %}

```graphql
mutation updateRole {
  updateRole(input: {
    id: "fea8sje-92jdnhc"
    name: "updated-role-name"
    permissions: [
      UserRead
      AlertRead
      AlertModify
    ]
    # 로그 유형별 RBAC 기능이 활성화된 경우에만 사용됨
    logTypeAccess:["AWS.ALB"]
    logTypeAccessKind: DENY
  })
  {
    role {
      이름
      id
      권한
      logTypeAccess 
      logTypeAccessKind
    }
  }
}
```

{% endtab %}
{% endtabs %}

#### 역할 삭제하기

```graphql
mutation deleteRole {
  deleteRole(input: {
    id: "e146c8d8-c6a5"
  })
    {
      id # 삭제 작업은 `role` 객체를 반환하지 않습니다. ID만 반환합니다.
    }
}
```

## 엔드투엔드 예시

아래에서는 [일반 작업](#common-operations) 예시를 바탕으로 엔드투엔드 흐름을 보여드리겠습니다.

#### **새 사용자 관리자 역할을 만들고 해당 역할에 사용자를 초대합니다.**

{% tabs %}
{% tab title="Python" %}

```python
# pip install gql aiohttp

from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

transport = AIOHTTPTransport(
  url="YOUR_PANTHER_API_URL",
  headers={"X-API-Key": "YOUR_API_KEY"},
)

client = Client(transport=transport, fetch_schema_from_transport=True)

create_user_admin = gql(
  """
  mutation newAdminRole {
    createRole (input: {
      name: "user-admin"
      permissions: [
        UserRead
        UserModify
        OrganizationAPITokenRead
        GeneralSettingsRead
      ]
    }) 
    {
      role {
        이름
        id
      }
    }
  }
  """
)

invite_user = gql(
  """
  mutation inviteUser($input: InviteUserInput!) {
    inviteUser (input: $input) {
      user {
        id
        email
      }
    }
  }
  """
)

new_role_data = client.execute(
  create_user_admin
)

print(f'새 역할 ID는 {new_role_data["createRole"]["role"]["id"]}입니다')

response_data = client.execute(
  invite_user,
  variable_values= {
    "input": {
      "email": "newAdmin@domain.local",
      "givenName": "user",
      "familyName": "admin",
      "role": {
        "kind": "ID",
        "value": new_role_data["createRole"]["role"]["id"],
      }
    }
  }
)

print(f'역할 {new_role_data["createRole"]["role"]["name"]}로 사용자 {response_data["inviteUser"]["user"]["email"]}를 성공적으로 초대했습니다.')
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import { GraphQLClient, gql } from "graphql-request";

const client = new GraphQLClient(
  "YOUR_PANTHER_API_URL",
  { headers: { "X-API-Key": "YOUR_API_KEY" } }
);

// `createUserAdmin`은 쿼리의 별칭입니다. 완전히 생략할 수 있습니다.
const createUserAdmin = gql`
  mutation newAdminRole {
    createRole(
      input: {
        name: "user-admin"
        permissions: [
          UserRead
          UserModify
          OrganizationAPITokenRead
          GeneralSettingsRead
        ]
      }
    ) {
      role {
        이름
        id
      }
    }
  }
`;

// `inviteUser`는 변이의 별칭입니다. 완전히 생략할 수 있습니다.
const inviteUser = gql`
  mutation inviteUser($input: InviteUserInput!) {
    inviteUser(input: $input) {
      user {
        id
        email
      }
    }
  }
`;

(async () => {
  try {
    const newRoleData = await client.request(createUserAdmin);

    const inviteUserOutput = await client.request(inviteUser, {
      input: {
        email: "newAdmin@domain.local",
        givenName: "user",
        familyName: "admin",
        role: {
          kind: "ID",
          value: newRoleData.createRole.role.id
        }
      }
    });

    console.log(
      `역할 ${newRoleData.createRole.role.name}로 사용자 ${inviteUserOutput.inviteUser.user.email}를 성공적으로 초대했습니다.`
    );
  } catch (err) {
    console.error(err);
  }
})();

```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.panther.com/ko/panther/api/graphql/user-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
