Kong Identity를 사용한 OAuth 2.0 인트로스펙션
Kong Identity를 사용한 OAuth 2.0 인트로스펙션 (OAuth 2.0 Introspection: Kong Identity)
이 문서는 OAuth 2.0 Introspection 플러그인을 Kong Identity 인증 서버의 인트로스펙션 엔드포인트와 연동해서 액세스 토큰을 검증하는 방법을 설명해요. 인트로스펙션 엔드포인트 호출에 필요한 환경 변수 세 가지를 소개하고, Konnect API와 Terraform으로 플러그인을 글로벌하게 설정하는 예제도 함께 다뤄요. Kong Identity에서 발급한 토큰을 Kong Gateway에서 검증하려는 분들에게 딱 맞는 가이드예요
출처: 문서
본문
Kong Identityv1.0+
플러그인이 Kong Identity 인증 서버의 인트로스펙션 엔드포인트를 사용해 액세스 토큰을 검증하도록 설정해요. 전체 튜토리얼은 Kong Identity로 OAuth 2.0 Introspection 플러그인 구성하기를 확인하세요.
환경 변수
-
AUTHORIZATION_HEADER_VALUE: 인트로스펙션 엔드포인트에 접근할 때Authorization헤더에 설정할 값이에요. Kong Identity의 경우 Base64로 인코딩된 클라이언트 ID와 시크릿이 담긴 basic auth 헤더, 즉Basic $ENCODED_CREDENTIALS형태가 돼요. -
INTROSPECTION_URL: 인트로스펙션 엔드포인트의 전체 URL이에요. Kong Identity라면https://a93xltvowjk8m1qe.us.identity.konghq.com/auth/introspect같은 형태가 돼요. -
CLAIM_NAME: Kong Identity 인증 서버에서 사용하는 클레임의 이름이에요.
플러그인 설정하기
전역
Konnect API
다음 요청을 보내세요:
curl -X POST https://{region}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/plugins/ \
--header "accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $KONNECT_TOKEN" \
--data '
{
"name": "oauth2-introspection",
"config": {
"introspection_url": "'$INTROSPECTION_URL'",
"authorization_value": "'$AUTHORIZATION_HEADER_VALUE'",
"consumer_by": "client_id",
"custom_claims_forward": [
"'$CLAIM_NAME'"
]
}
}
'
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
-
region: 여러분의 Kong Konnect가 호스팅되고 운영되는 지리적 지역이에요. -
KONNECT_TOKEN: Konnect 계정과 연결된 개인 액세스 토큰(PAT)이에요. -
controlPlaneId: 컨트롤 플레인의id예요.
지역별 URL과 개인 액세스 토큰에 대해 자세히 알아보려면 Konnect Control Planes Config API 레퍼런스를 확인하세요.
Terraform
사전 준비: 개인 액세스 토큰 구성하기
terraform {
required_providers {
konnect = {
source = "kong/konnect"
}
}
}
provider "konnect" {
personal_access_token = "$KONNECT_TOKEN"
server_url = "https://us.api.konghq.com/"
}
Konnect Gateway 플러그인을 생성하려면 Terraform 구성에 다음 내용을 추가하세요:
resource "konnect_gateway_plugin_oauth2_introspection" "my_oauth2_introspection" {
enabled = true
config = {
introspection_url = var.introspection_url
authorization_value = var.authorization_header_value
consumer_by = "client_id"
custom_claims_forward = [var.claim_name]
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
}
이 예제에서는 다음 변수들을 매니페스트에 추가해야 해요. TF_VAR_name=value 형식으로 설정하면 런타임에 값을 지정할 수 있어요.
variable "authorization_header_value" {
type = string
}
variable "introspection_url" {
type = string
}
variable "claim_name" {
type = string
}
서비스
Konnect API
다음 요청을 보내세요:
curl -X POST https://{region}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/services/{serviceId}/plugins/ \
--header "accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $KONNECT_TOKEN" \
--data '
{
"name": "oauth2-introspection",
"config": {
"introspection_url": "'$INTROSPECTION_URL'",
"authorization_value": "'$AUTHORIZATION_HEADER_VALUE'",
"consumer_by": "client_id",
"custom_claims_forward": [
"'$CLAIM_NAME'"
]
}
}
'
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
-
region: 여러분의 Kong Konnect가 호스팅되고 운영되는 지리적 지역이에요. -
KONNECT_TOKEN: Konnect 계정과 연결된 개인 액세스 토큰(PAT)이에요. -
controlPlaneId: 컨트롤 플레인의id예요. -
serviceId: 플러그인 구성이 대상으로 할 서비스의id예요.
지역별 URL과 개인 액세스 토큰에 대해 자세히 알아보려면 Konnect Control Planes Config API 레퍼런스를 확인하세요.
Terraform
사전 준비: 개인 액세스 토큰 구성하기
terraform {
required_providers {
konnect = {
source = "kong/konnect"
}
}
}
provider "konnect" {
personal_access_token = "$KONNECT_TOKEN"
server_url = "https://us.api.konghq.com/"
}
Konnect Gateway 플러그인을 생성하려면 Terraform 구성에 다음 내용을 추가하세요:
resource "konnect_gateway_plugin_oauth2_introspection" "my_oauth2_introspection" {
enabled = true
config = {
introspection_url = var.introspection_url
authorization_value = var.authorization_header_value
consumer_by = "client_id"
custom_claims_forward = [var.claim_name]
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
service = {
id = konnect_gateway_service.my_service.id
}
}
이 예제에서는 다음 변수들을 매니페스트에 추가해야 해요. TF_VAR_name=value 형식으로 설정하면 런타임에 값을 지정할 수 있어요.
variable "authorization_header_value" {
type = string
}
variable "introspection_url" {
type = string
}
variable "claim_name" {
type = string
}
라우트
Konnect API
다음 요청을 보내세요:
curl -X POST https://{region}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/routes/{routeId}/plugins/ \
--header "accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $KONNECT_TOKEN" \
--data '
{
"name": "oauth2-introspection",
"config": {
"introspection_url": "'$INTROSPECTION_URL'",
"authorization_value": "'$AUTHORIZATION_HEADER_VALUE'",
"consumer_by": "client_id",
"custom_claims_forward": [
"'$CLAIM_NAME'"
]
}
}
'
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
-
region: 여러분의 Kong Konnect가 호스팅되고 운영되는 지리적 지역이에요. -
KONNECT_TOKEN: Konnect 계정과 연결된 개인 액세스 토큰(PAT)이에요. -
controlPlaneId: 컨트롤 플레인의id예요. -
routeId: 플러그인 구성이 대상으로 할 라우트의id예요.
지역별 URL과 개인 액세스 토큰에 대해 자세히 알아보려면 Konnect Control Planes Config API 레퍼런스를 확인하세요.
Terraform
사전 준비: 개인 액세스 토큰 구성하기
terraform {
required_providers {
konnect = {
source = "kong/konnect"
}
}
}
provider "konnect" {
personal_access_token = "$KONNECT_TOKEN"
server_url = "https://us.api.konghq.com/"
}
Konnect Gateway 플러그인을 생성하려면 Terraform 구성에 다음 내용을 추가하세요:
resource "konnect_gateway_plugin_oauth2_introspection" "my_oauth2_introspection" {
enabled = true
config = {
introspection_url = var.introspection_url
authorization_value = var.authorization_header_value
consumer_by = "client_id"
custom_claims_forward = [var.claim_name]
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
route = {
id = konnect_gateway_route.my_route.id
}
}
이 예제에서는 다음 변수들을 매니페스트에 추가해야 해요. TF_VAR_name=value 형식으로 설정하면 런타임에 값을 지정할 수 있어요.
variable "authorization_header_value" {
type = string
}
variable "introspection_url" {
type = string
}
variable "claim_name" {
type = string
}
관련 리소스
더 알아보기 (Learn more)
- Kong Identity와 함께 OAuth 2.0 Introspection 플러그인을 설정하는 전체 튜토리얼이에요 — Configure the OAuth 2.0 Introspection plugin with Kong Identity
- 리전별 URL과 퍼스널 액세스 토큰 사용법을 확인할 수 있는 Konnect Control Planes Config API 레퍼런스예요 — Konnect Control Planes Config API reference
- Kong Gateway의 인증 개념과 옵션을 전반적으로 정리한 문서예요 — Kong Gateway authentication
- OAuth 2.0 인증 플러그인의 설정 옵션과 동작 방식을 설명하는 레퍼런스예요 — OAuth 2.0 Authentication plugin