OpenID Connect: 보호 리소스 메타데이터
OpenID Connect: 보호 리소스 메타데이터 (Protected Resource Metadata)
OpenID Connect 플러그인을 사용하면 이 API를 RFC 9728에서 정의한 OAuth 2.0 보호 리소스로 알릴 수 있어요. 그러면 MCP 클라이언트를 포함한 OAuth·OpenID Connect 클라이언트가 어떤 인가 서버가 이 API를 보호하는지, 어떤 스코프를 지원하는지 자동으로 발견할 수 있죠. 설정이 완료되면 플러그인이 잘 알려진 URI에서 메타데이터 문서를 제공하고, 401 응답의 WWW-Authenticate 헤더에 resource_metadata 속성을 담아 줘요. 이 문서에서는 JWT 베어러 토큰 인증과 함께 보호 리소스 메타데이터를 decK와 Admin API로 설정하는 방법을 단계별로 살펴봐요
출처: 문서
본문
보호 리소스 메타데이터v3.16+
OpenID Connect 플러그인을 사용해 이 API를 RFC 9728에서 정의한 OAuth 2.0 보호 리소스로 알리세요. 이렇게 하면 MCP(Model Context Protocol) 클라이언트를 포함한 OAuth 및 OpenID Connect 클라이언트가 어떤 인가 서버가 이 API를 보호하는지, 어떤 스코프를 지원하는지 자동으로 발견할 수 있어요.
설정하고 나면 OIDC 플러그인이 resource에서 파생한 well-known URI에서 메타데이터 문서를 제공하고, 401 Unauthorized 응답의 WWW-Authenticate 헤더에 resource_metadata 속성(scopes_supported가 설정된 경우 scope 속성도)을 추가해요.
이 예제는 보호 리소스 메타데이터를 JWT 액세스 토큰(bearer) 인증과 결합해요.
토큰을 제시하지 않거나 잘못된 토큰을 제시한 클라이언트는 WWW-Authenticate 헤더가 메타데이터 문서를 가리키는 401 응답을 받게 돼요.
자세한 내용은 보호 리소스 메타데이터를 참고하세요.
사전 준비
- 이 API에 bearer 토큰을 발급하는 identity provider가 필요해요.
환경 변수
-
ISSUER: 이 API를 보호하는 인가 서버의 issuer 인증 URL이에요. 예를 들어 Keycloak을 IdP로 사용한다면 issuer URL은 다음과 같아요:http://localhost:8080/realms/example-realm. -
RESOURCE: 이 보호 리소스의 URI예요. 예를 들어https://api.example.com/mcp같은 값이에요. well-known 메타데이터 엔드포인트 경로를 도출하는 데도 사용돼요. -
SCOPE: 이 보호 리소스가 지원하는 스코프예요. 예를 들어mcp:read같은 값이에요. -
TOKEN_SALT: 매번 동기화할 때마다 세션 자격 증명이 다시 생성되지 않도록 하기 위해 decK가 요구하는(v1.59 이상) 랜덤 문자열이에요. 이 파라미터는 다른 포맷에서는 선택 사항이에요. 예를 들어openssl rand -base64 16으로 생성할 수 있어요.
플러그인 설정
전역
decK
이 섹션을 kong.yaml 설정 파일에 추가하세요:
_format_version: "3.0"
plugins:
- name: openid-connect
config:
issuer: ${{ env "DECK_ISSUER" }}
auth_methods:
- bearer
protected_resource_metadata:
resource: ${{ env "DECK_RESOURCE" }}
authorization_servers:
- ${{ env "DECK_ISSUER" }}
scopes_supported:
- ${{ env "DECK_SCOPE" }}
cache_tokens_salt: ${{ env "DECK_TOKEN_SALT" }}
{: data-file="kong.yaml" data-tool="deck" }
Admin API
다음 요청을 보내세요:
curl -i -X POST http://localhost:8001/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "openid-connect",
"config": {
"issuer": "'$ISSUER'",
"auth_methods": [
"bearer"
],
"protected_resource_metadata": {
"resource": "'$RESOURCE'",
"authorization_servers": [
"'$ISSUER'"
],
"scopes_supported": [
"'$SCOPE'"
]
},
"cache_tokens_salt": "'$TOKEN_SALT'"
}
}
'
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": "openid-connect",
"config": {
"issuer": "'$ISSUER'",
"auth_methods": [
"bearer"
],
"protected_resource_metadata": {
"resource": "'$RESOURCE'",
"authorization_servers": [
"'$ISSUER'"
],
"scopes_supported": [
"'$SCOPE'"
]
},
"cache_tokens_salt": "'$TOKEN_SALT'"
}
}
'
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
-
region: Kong Konnect가 호스팅되고 운영되는 지리적 리전이에요. -
KONNECT_TOKEN: Konnect 계정에 연결된 개인 액세스 토큰(PAT)이에요. -
controlPlaneId: 컨트롤 플레인의id예요.
리전별 URL과 개인 액세스 토큰에 대해 알아보려면 Konnect Control Planes Config API 레퍼런스를 참고하세요.
KIC
echo "
apiVersion: configuration.konghq.com/v1
kind: KongClusterPlugin
metadata:
name:
namespace: kong
annotations:
kubernetes.io/ingress.class: kong
labels:
global: 'true'
config:
issuer: '$ISSUER'
auth_methods:
- bearer
protected_resource_metadata:
resource: '$RESOURCE'
authorization_servers:
- '$ISSUER'
scopes_supported:
- '$SCOPE'
cache_tokens_salt: '$TOKEN_SALT'
plugin: openid-connect
" | kubectl apply -f -
Terraform
사전 준비: 개인 액세스 토큰 구성
terraform {
required_providers {
konnect = {
source = "kong/konnect"
}
}
}
provider "konnect" {
personal_access_token = "$KONNECT_TOKEN"
server_url = "https://us.api.konghq.com/"
}
Konnect Gateway Plugin을 생성하려면 Terraform 구성에 다음 내용을 추가하세요:
resource "konnect_gateway_plugin_openid_connect" "my_openid_connect" {
enabled = true
config = {
issuer = var.issuer
auth_methods = ["bearer"]
protected_resource_metadata = {
resource = var.resource
authorization_servers = [var.issuer]
scopes_supported = [var.scope]
}
cache_tokens_salt = var.token_salt
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
}
이 예제를 사용하려면 매니페스트에 다음 변수를 추가해야 해요. TF_VAR_name=value를 설정하면 런타임에 값을 지정할 수 있어요.
variable "issuer" {
type = string
}
variable "resource" {
type = string
}
variable "scope" {
type = string
}
variable "token_salt" {
type = string
}
서비스
decK
이 섹션을 kong.yaml 설정 파일에 추가하세요:
_format_version: "3.0"
plugins:
- name: openid-connect
service: serviceName|Id
config:
issuer: ${{ env "DECK_ISSUER" }}
auth_methods:
- bearer
protected_resource_metadata:
resource: ${{ env "DECK_RESOURCE" }}
authorization_servers:
- ${{ env "DECK_ISSUER" }}
scopes_supported:
- ${{ env "DECK_SCOPE" }}
cache_tokens_salt: ${{ env "DECK_TOKEN_SALT" }}
{: data-file="kong.yaml" data-tool="deck" }
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
serviceName|Id: 플러그인 구성이 대상으로 할 서비스의id또는name이에요.
Admin API
다음 요청을 보내세요:
curl -i -X POST http://localhost:8001/services/{serviceName|Id}/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "openid-connect",
"config": {
"issuer": "'$ISSUER'",
"auth_methods": [
"bearer"
],
"protected_resource_metadata": {
"resource": "'$RESOURCE'",
"authorization_servers": [
"'$ISSUER'"
],
"scopes_supported": [
"'$SCOPE'"
]
},
"cache_tokens_salt": "'$TOKEN_SALT'"
}
}
'
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
serviceName|Id: 플러그인 구성이 대상으로 할 서비스의id또는name이에요.
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": "openid-connect",
"config": {
"issuer": "'$ISSUER'",
"auth_methods": [
"bearer"
],
"protected_resource_metadata": {
"resource": "'$RESOURCE'",
"authorization_servers": [
"'$ISSUER'"
],
"scopes_supported": [
"'$SCOPE'"
]
},
"cache_tokens_salt": "'$TOKEN_SALT'"
}
}
'
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
-
region: Kong Konnect가 호스팅되고 운영되는 지리적 리전이에요. -
KONNECT_TOKEN: Konnect 계정에 연결된 개인 액세스 토큰(PAT)이에요. -
controlPlaneId: 컨트롤 플레인의id예요. -
serviceId: 플러그인 구성이 대상으로 할 서비스의id예요.
리전별 URL과 개인 액세스 토큰에 대해 알아보려면 Konnect Control Planes Config API 레퍼런스를 참고하세요.
KIC
echo "
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name:
namespace: kong
annotations:
kubernetes.io/ingress.class: kong
config:
issuer: '$ISSUER'
auth_methods:
- bearer
protected_resource_metadata:
resource: '$RESOURCE'
authorization_servers:
- '$ISSUER'
scopes_supported:
- '$SCOPE'
cache_tokens_salt: '$TOKEN_SALT'
plugin: openid-connect
" | kubectl apply -f -
다음으로, service 리소스에 어노테이션을 붙여 KongPlugin 리소스를 적용하세요:
kubectl annotate -n kong service SERVICE_NAME konghq.com/plugins=
Terraform
사전 준비: 개인 액세스 토큰 구성
terraform {
required_providers {
konnect = {
source = "kong/konnect"
}
}
}
provider "konnect" {
personal_access_token = "$KONNECT_TOKEN"
server_url = "https://us.api.konghq.com/"
}
Konnect Gateway Plugin을 생성하려면 Terraform 구성에 다음 내용을 추가하세요:
resource "konnect_gateway_plugin_openid_connect" "my_openid_connect" {
enabled = true
config = {
issuer = var.issuer
auth_methods = ["bearer"]
protected_resource_metadata = {
resource = var.resource
authorization_servers = [var.issuer]
scopes_supported = [var.scope]
}
cache_tokens_salt = var.token_salt
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
service = {
id = konnect_gateway_service.my_service.id
}
}
이 예제를 사용하려면 매니페스트에 다음 변수를 추가해야 해요. TF_VAR_name=value를 설정하면 런타임에 값을 지정할 수 있어요.
variable "issuer" {
type = string
}
variable "resource" {
type = string
}
variable "scope" {
type = string
}
variable "token_salt" {
type = string
}
라우트
decK
이 섹션을 kong.yaml 설정 파일에 추가하세요:
_format_version: "3.0"
plugins:
- name: openid-connect
route: routeName|Id
config:
issuer: ${{ env "DECK_ISSUER" }}
auth_methods:
- bearer
protected_resource_metadata:
resource: ${{ env "DECK_RESOURCE" }}
authorization_servers:
- ${{ env "DECK_ISSUER" }}
scopes_supported:
- ${{ env "DECK_SCOPE" }}
cache_tokens_salt: ${{ env "DECK_TOKEN_SALT" }}
{: data-file="kong.yaml" data-tool="deck" }
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
routeName|Id: 플러그인 구성이 대상으로 할 라우트의id또는name이에요.
Admin API
다음 요청을 보내세요:
curl -i -X POST http://localhost:8001/routes/{routeName|Id}/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "openid-connect",
"config": {
"issuer": "'$ISSUER'",
"auth_methods": [
"bearer"
],
"protected_resource_metadata": {
"resource": "'$RESOURCE'",
"authorization_servers": [
"'$ISSUER'"
],
"scopes_supported": [
"'$SCOPE'"
]
},
"cache_tokens_salt": "'$TOKEN_SALT'"
}
}
'
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
routeName|Id: 플러그인 구성이 대상으로 할 라우트의id또는name이에요.
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": "openid-connect",
"config": {
"issuer": "'$ISSUER'",
"auth_methods": [
"bearer"
],
"protected_resource_metadata": {
"resource": "'$RESOURCE'",
"authorization_servers": [
"'$ISSUER'"
],
"scopes_supported": [
"'$SCOPE'"
]
},
"cache_tokens_salt": "'$TOKEN_SALT'"
}
}
'
다음 자리표는 반드시 본인의 값으로 바꿔야 해요:
-
region: Kong Konnect가 호스팅되고 운영되는 지리적 지역이에요. -
KONNECT_TOKEN: Konnect 계정과 연결된 개인 액세스 토큰(PAT)이에요. -
controlPlaneId: 컨트롤 플레인의id예요. -
routeId: 플러그인 구성이 대상으로 삼을 라우트의id예요.
지역별 URL과 개인 액세스 토큰에 대해 자세히 알아보려면 Konnect Control Planes Config API 레퍼런스 문서를 확인하세요.
KIC
echo "
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name:
namespace: kong
annotations:
kubernetes.io/ingress.class: kong
config:
issuer: '$ISSUER'
auth_methods:
- bearer
protected_resource_metadata:
resource: '$RESOURCE'
authorization_servers:
- '$ISSUER'
scopes_supported:
- '$SCOPE'
cache_tokens_salt: '$TOKEN_SALT'
plugin: openid-connect
" | kubectl apply -f -
다음으로, httproute 또는 ingress 리소스에 어노테이션을 추가해서 KongPlugin 리소스를 적용하세요:
Gateway API
kubectl annotate -n kong httproute konghq.com/plugins=
Ingress
kubectl annotate -n kong ingress konghq.com/plugins=
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_openid_connect" "my_openid_connect" {
enabled = true
config = {
issuer = var.issuer
auth_methods = ["bearer"]
protected_resource_metadata = {
resource = var.resource
authorization_servers = [var.issuer]
scopes_supported = [var.scope]
}
cache_tokens_salt = var.token_salt
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
route = {
id = konnect_gateway_route.my_route.id
}
}
이 예제에서는 매니페스트에 다음 변수들이 추가되어야 해요. TF_VAR_name=value 형식으로 설정하면 런타임에 값을 지정할 수 있어요.
variable "issuer" {
type = string
}
variable "resource" {
type = string
}
variable "scope" {
type = string
}
variable "token_salt" {
type = string
}
관련 리소스
더 알아보기 (Learn more)
- OIDC 플러그인 문서에서 보호 리소스 메타데이터의 동작 방식과 설정 옵션을 더 자세히 확인할 수 있어요 — Protected resource metadata
- Kong Gateway에서 OpenID Connect 플러그인 전반을 이해하는 데 도움이 되는 가이드예요 — OpenID Connect in Kong Gateway
- Kong Gateway의 인증 개념과 다양한 인증 방식을 함께 살펴보면 좋아요 — Authentication in Kong Gateway
- OpenID Connect 플러그인을 직접 따라 해볼 수 있는 튜토리얼 모음이에요 — OpenID Connect tutorials
- 예제에서 사용하는 decK 설정 파일 작성법을 익히면 구성 이해에 도움이 돼요 —
kong.yaml