ACL: 클레임 표현식으로 토픽 접근 허용하기
ACL: 클레임 표현식으로 토픽 접근 허용하기 (ACLs: Allow access to topics using a claim expression)
이 문서는 클레임 표현식을 사용해 토픽 접근을 허용하는 ACL 정책 설정 방법을 설명해요. topic_prefix 클레임에 담긴 접두사로 시작하는 모든 토픽에 읽기, 쓰기 같은 전체 작업 권한을 부여하는 정책이에요. Konnect API와 Terraform 두 가지 방식으로 정책을 구성하는 예시를 단계별로 보여줘요. Kong Identity OAuth로 클레임을 준비하는 전체 튜토리얼과 표현식 참고 문서도 함께 안내해요
출처: 문서
본문
클레임 표현식을 사용해 토픽 접근 허용하기
이 ACL 정책은 topic_prefix 클레임에 지정된 접두사가 붙은 모든 토픽에 대한 전체 접근 권한을 부여해요.
Kong Identity 인증 서버와 클레임을 구성하고 ACL 정책에서 클레임을 참조하는 방법에 대한 전체 튜토리얼은 Kong Identity OAuth로 Kong Event Gateway 설정하기를 참고하세요.
Kong Event Gateway의 표현식에 대해 자세히 알아보려면 표현식 참조를 확인하세요.
정책 설정하기
클러스터 단계
Konnect API
curl -X POST https://{region}.api.konghq.com/v1/event-gateways/{eventGatewayId}/virtual-clusters/{virtualClusterId}/cluster-policies \
--header "accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $KONNECT_TOKEN" \
--data '
{
"name": "acl_policy",
"type": "acls",
"config": {
"rules": [
{
"resource_type": "topic",
"action": "allow",
"operations": [
{
"name": "describe"
},
{
"name": "describe_configs"
},
{
"name": "read"
},
{
"name": "write"
}
],
"resource_names": "[context.auth.token.claims.topic_prefix + \"*\"]"
}
]
}
}
'
다음 플레이스홀더는 여러분의 값으로 바꿔야 해요:
-
region: 여러분의 Kong Konnect가 호스팅되고 운영되는 지리적 지역이에요. -
KONNECT_TOKEN: Konnect 계정에 연결된 개인 액세스 토큰(PAT)이에요. -
virtualClusterId: Virtual Cluster의id예요. -
eventGatewayId: Event Gateway의id예요. -
eventGatewayListenerId: Event Gateway Listener의id예요.
지역별 URL과 개인 액세스 토큰에 대해 알아보려면 Konnect Event Gateway API 참조를 확인하세요.
Terraform
사전 준비: 개인 액세스 토큰 구성하기
terraform {
required_providers {
konnect-beta = {
source = "kong/konnect-beta"
}
}
}
provider "konnect-beta" {
personal_access_token = "$KONNECT_TOKEN"
server_url = "https://us.api.konghq.com/"
}
Terraform 구성에 다음을 추가하세요:
resource "konnect_event_gateway_cluster_policy_acls" "my_virtual_cluster_policy_acls" {
provider = konnect-beta
type = "acls"
config = {
rules = [
{
resource_type = "topic"
action = "allow"
operations = [
{
name = "describe"
},
{
name = "describe_configs"
},
{
name = "read"
},
{
name = "write"
} ]
resource_names = "[context.auth.token.claims.topic_prefix + \"*\"]"
} ]
}
virtual_cluster_id = konnect_event_gateway_virtual_cluster.my_virtual_cluster.id
gateway_id = konnect_event_gateway.my_event_gateway.id
}
kongctl
다음 예제는 새로운 acls 정책을 생성해요.
event_gateways:
- ref: eventGatewayName
name: eventGatewayName
virtual_clusters:
- ref: virtualClusterName
name: virtualClusterName
cluster_policies:
- ref: acl_policy
type: acls
acls:
name: acl_policy
config:
rules:
- resource_type: topic
action: allow
operations:
- name: describe
- name: describe_configs
- name: read
- name: write
resource_names: '[context.auth.token.claims.topic_prefix + "*"]'
{: data-file="event_gateway_policy.yaml" data-tool="kongctl" }
다음 플레이스홀더는 여러분의 값으로 바꿔야 해요:
-
eventGatewayName: 여러분의 Event Gateway의name이에요. -
virtualClusterName: Virtual Cluster의name이에요.
관련 리소스
더 알아보기 (Learn more)
- Kong Identity OAuth 인증 서버와 클레임 구성 전체 튜토리얼 — Set up Kong Event Gateway with Kong Identity OAuth
- Kong Event Gateway에서 사용하는 표현식 문법 참조 문서 — expressions reference
- 지역별 URL과 개인 액세스 토큰 등 Konnect Event Gateway API 참조 — Konnect Event Gateway API reference
- ACL 정책이 적용되는 대상인 가상 클러스터 엔티티 설명 — Virtual clusters
- 정책 엔티티의 개념과 구성 방법 설명 — Policies
- 네임스페이스와 ACL로 Kafka 토픽을 제품화하는 심화 how-to — How-to: Productize Kafka topics with namespaces and ACLs