본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Admin API로 슈퍼 관리자 만들기

원문 보기 위키 갱신

Admin API로 슈퍼 관리자 만들기 (Super Admin)

RBAC이 활성화된 Kong Gateway에서 Admin API로 슈퍼 관리자(Super Admin) 사용자를 만드는 방법을 안내해요. /rbac/users/ 엔드포인트로 RBAC 사용자를 생성한 뒤 super-admin 역할에 연결하는 과정을 차례대로 따라 해 봐요. 마지막에는 역할이 제대로 할당됐는지 검증하고 실습 환경을 정리하는 방법까지 확인해요

출처: 문서

본문

핵심 요약

Admin API로 Kong Gateway 슈퍼 관리자(Super Admin)는 어떻게 만들어요? RBAC를 활성화한 후에는 /rbac/users/ 엔드포인트로 POST 요청을 보내서 슈퍼 관리자 사용자를 만들 수 있어요. 그다음 해당 사용자를 super-admin 역할에 연결해요.

사전 준비

RBAC가 활성화된 상태로 실행 중인 Kong Gateway

이 튜토리얼에는 Kong Gateway Enterprise가 필요해요.

  1. 라이선스를 환경 변수로 내보내세요:

    export KONG_LICENSE_DATA='LICENSE-CONTENTS-GO-HERE'
    
  2. RBAC를 활성화한 상태로 퀵스타트 스크립트를 실행해요:

    curl -Ls get.konghq.com/quickstart | bash -s -- -e "KONG_LICENSE_DATA" \
         -e "KONG_ENFORCE_RBAC=on" \
         -e "KONG_ADMIN_GUI_AUTH=basic-auth" \
         -e "KONG_PASSWORD=kong" \
         -e 'KONG_ADMIN_GUI_SESSION_CONF={"secret":"kong", "cookie_lifetime":300000, "cookie_renew":200000, "cookie_name":"kong_cookie", "cookie_secure":false, "cookie_samesite": "off"}'
    

    값에 대한 자세한 내용은 RBAC 레퍼런스를 참고하세요. Kong Gateway가 준비되면 다음 메시지가 표시돼요:

    Kong Gateway Ready
    

환경 변수 설정

다음 변수를 설정해요:

  • KONG_ADMIN_TOKEN: Kong Gateway를 설정할 때 지정한 kong_password 변수예요.
  • ADMIN_NAME: 슈퍼 관리자 역할에 연결될 RBAC 사용자의 이름이에요.
  • USER_TOKEN: Admin API에 제시할 인증 토큰이에요. 예를 들면 다음과 같아요:
export KONG_ADMIN_TOKEN="kong"
export ADMIN_NAME="tim"
export USER_TOKEN="my-admin-token"

슈퍼 관리자(super-admin) RBAC 사용자 만들기

  1. RBAC 사용자를 만들어요:

    curl -X POST "http://localhost:8001/rbac/users" \
         --no-progress-meter --fail-with-body  \
         -H "Accept: application/json"\
         -H "Content-Type: application/json"\
         -H "Kong-Admin-Token: $KONG_ADMIN_TOKEN" \
         --json '{
           "name": "'$ADMIN_NAME'",
           "user_token": "'$USER_TOKEN'"
         }'
    
  2. 사용자를 super-admin 역할에 연결해요:

    curl -X POST "http://localhost:8001/rbac/users/$ADMIN_NAME/roles" \
         --no-progress-meter --fail-with-body  \
         -H "Accept: application/json"\
         -H "Content-Type: application/json"\
         -H "Kong-Admin-Token: $KONG_ADMIN_TOKEN" \
         --json '{
           "roles": "super-admin"
         }'
    

검증

/rbac/users/{user}/roles 엔드포인트를 사용해서 super-admin 역할이 RBAC 사용자에게 올바르게 할당됐는지 확인할 수 있어요:

curl "http://localhost:8001/rbac/users/$ADMIN_NAME/roles" \
     --no-progress-meter --fail-with-body  \
     -H "Kong-Admin-Token: $KONG_ADMIN_TOKEN"

제대로 설정됐다면 응답 본문은 다음과 같아요:

{
	"user": {
		"enabled": true,
		"updated_at": 1737490456,
		"comment": null,
		"id": "49a1d4e5-e306-4b2d-a343-8973afd1360d",
		"created_at": 1737490456,
		"user_token_ident": "40a46",
		"name": "tim",
		"user_token": "$2b$09$578ORHJCMmpvDTVbB6hDkeIDsXZkUcgBQRemXdrwH2ex8IYBKWSE."
	},
	"roles": [
		{
			"created_at": 1737488148,
			"role_source": "local",
			"name": "super-admin",
			"updated_at": 1737488148,
			"ws_id": "fcde03f2-738e-4b29-a63e-fe0cdcc9a76e",
			"comment": "Full access to all endpoints, across all workspaces",
			"id": "3d7d7bfc-b894-4d9f-b28f-c9396bce201a"
		}
	]
}

{:.no-copy-code}

사용자에게 할당된 RBAC 역할이 super-admin인 것을 확인할 수 있어요.

정리

Kong Gateway 컨테이너 삭제

curl -Ls https://get.konghq.com/quickstart | bash -s -- -d

관련 자료

더 알아보기 (Learn more)

  • RBAC 개념과 활성화 방법을 먼저 살펴봐요 — RBAC
  • 사용자 생성에 사용되는 Admin API 엔드포인트 명세예요 — /rbac/users/
  • 커스텀 권한으로 RBAC 사용자를 만드는 심화 방법이에요 — Create an RBAC user with custom permissions
  • 슈퍼 관리자와 관련된 관리자 엔티티를 함께 확인해요 — Gateway Admins