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

AI Gateway 2.0의 OpenID Connect 인증

원문 보기 위키 갱신

AI Gateway 2.0의 OpenID Connect 인증 (OpenID Connect authentication with AI Gateway 2.0)

AI Gateway는 AI Auth Strategy를 사용해 AI Model, AI Agent, AI MCP Server로 향하는 호출자를 인증하고, 설정에 따라 사용량을 AI Consumer에 귀속시키거나 인증되지 않은 요청을 거절할 수 있어요. OpenID Connect AI Auth Strategy를 쓰면 AI Consumer가 이미 OIDC 호환 IdP에서 받은 JWT bearer 토큰이나 OAuth 2.0 grant를 그대로 사용하니까 정적 API 키를 발급하거나 교체할 필요가 없어요. 이 문서에서는 IdP와의 연동 방식 같은 동작 원리부터 지원되는 플로우와 grant, 권한 부여, 클라이언트 인증, FAPI·멀티 IdP·토큰 교환 같은 고급 기능까지 차례로 살펴봐요

출처: 문서

본문

AI Gateway는 AI Auth Strategy를 사용해서 AI Model, AI Agent, AI MCP Server로 향하는 호출자를 인증해요. 설정 방법에 따라 사용량을 AI Consumer에 귀속시키고, 인증되지 않은 요청은 거부할 수도 있어요.

OpenID Connect AI Auth Strategy를 사용하면, AI Gateway는 AI Consumer가 OIDC 호환 identity provider(IdP)에서 이미 발급받은 JWT bearer 토큰이나 OAuth 2.0 grant를 그대로 받아들여요. key auth를 사용할 때처럼 정적 API 키를 발급하거나 교체할 필요가 없죠.

AI Consumer가 이미 엔터프라이즈 IdP를 통해 인증하고 있다면 OpenID Connect를 사용하세요. AI Consumer가 여러분이 관리하는 내부 도구나 스크립트라면 key auth를 사용하세요. 하나의 AI Model은 두 가지를 동시에 사용할 수 있어요. 예를 들어 내부 자동화에는 key auth를, 사용자 대면 애플리케이션에는 OpenID Connect를 쓰는 식이죠. 요청이 두 전략 중 하나라도 만족하면 인증된 것으로 처리돼요. AI Agent와 AI MCP Server는 각각 AI Auth Strategy를 하나씩만 받아들여요.

이 전략의 config 객체는 Kong Gateway의 OpenID Connect plugin으로 그대로 전달돼요. AI Gateway는 스키마에 플러그인 필드의 일부를 문서화하고, 나머지는 고급 사용 사례를 위해 그대로 받아들여요.

동작 방식

OpenID Connect는 IdP와 federation을 맺는 방식으로 동작해요. IdP는 계정 자격 증명을 저장하고 호출자를 인증하죠. AI Gateway는 자격 증명을 직접 관리하는 대신 그 인증을 신뢰해요. Konnect는 이 용도로 쓸 수 있는 관리형 IdP인 Kong Identity를 제공하고, 이미 운영 중인 OIDC 호환 provider가 있다면 AI Auth Strategy를 그쪽으로 향하게 할 수도 있어요.

OpenID Connect AI Auth Strategy는 한 번 만들어 두고, name이나 id로 하나 이상의 AI Model, AI Agent, 또는 AI MCP Server에 access.auth_strategies 배열을 통해 연결해요. AI MCP Server는 conversion-listener, listener, passthrough-listener 모드에서만 AI Auth Strategy를 받아들여요. 이 세 모드가 들어오는 MCP 트래픽을 직접 수락하는 모드예요. 전체 모드 레퍼런스는 AI MCP Server entity를 참고하세요.

인증이 끝나면 토큰은 AI Consumer, Kong Identity principal, 혹은 둘 다에 매핑될 수 있어요. 이 매핑이 어떻게 동작하는지는 AI Auth Strategy entity 문서의 Identity 매핑 섹션을 참고하세요.

AI Model, AI Agent, 또는 AI MCP Server에 AI Auth Strategy를 연결하면, AI Gateway가 내부적으로 Request Termination policy가 적용된 공유 anonymous AI Consumer를 자동으로 프로비저닝하고, auth strategy의 실패 경로를 그쪽으로 향하게 해요. 기본적으로 이는 인증에 실패한 모든 요청(예: 자격 증명이 없는 경우, 유효하지 않은 토큰, 알려진 AI Consumer나 Kong Identity principal에 매핑되지 않는 유효한 토큰)이 AI Model, AI Agent, 또는 AI MCP Server에 도달하기 전에 그 anonymous AI Consumer로 라우팅되어 401 Unauthorized로 거부된다는 뜻이에요.

다음 두 설정은 이 기본 termination을 완전히 끄지 않으면서 특정 요청을 그 대상에서 제외할 수 있게 해요:

  • config.consumer_optional: true (openid-connect 전용): 어떤 AI Consumer에도 매핑되지 않는 유효한 토큰은 termination되는 대신 진행돼요. 요청은 여전히 AI Consumer identity 없이 처리되죠.
  • config.principals.error_on_miss: false (key-auth 및 openid-connect): 어떤 Kong Identity principal과도 일치하지 않는 요청은 termination되는 대신 진행돼요.

두 설정 모두 자격 증명이 없는 요청이나 유효하지 않은 토큰에는 영향을 주지 않아요. 그런 요청은 consumer_optional이나 principals.error_on_miss 설정과 상관없이 항상 anonymous AI Consumer를 통해 termination돼요.

다음 다이어그램은 OpenID Connect AI Auth Strategy가 연결된 AI Model, AI Agent, 또는 AI MCP Server에 대한 요청의 세 가지 결과를 보여줘요:

 
sequenceDiagram
    participant Client as AI Consumer
    participant Auth as OpenID Connect AI Auth Strategy
    participant Anon as Anonymous AI Consumer
(Request Termination) participant Entity as AI Model, AI Agent,
or AI MCP Server Client->>Auth: Request with bearer token alt Valid token, maps to a known AI Consumer Auth->>Entity: Proxies request as that AI Consumer Entity-->>Client: Response else No token, or invalid token Auth->>Anon: Routes to anonymous AI Consumer Anon-->>Client: 401 Unauthorized else Valid token, no Consumer/principal match,
consumer_optional or principals.error_on_miss set Auth->>Entity: Proxies request without an AI Consumer identity Entity-->>Client: Response end

ACL을 사용한 authorization

인증과 authorization은 별개의 단계예요. AI Auth Strategy는 누가 호출하는지만 확인할 뿐이에요. 그 호출자가 어떤 AI Model, AI Agent, 또는 AI MCP Server에 도달할 수 있는지는 결정하지 않죠. AI Consumer, AI Consumer Group, 또는 Authenticated Group(토큰의 OAuth 2.0 scope나 claim에서 파생되는 dynamic group) 기준으로 접근을 제한하려면 entity 자체에 access.acls를 사용하세요. 모든 호출자가 하나의 IdP를 공유하는 경우에도 이 구분이 중요해요. 여러 AI Model이 같은 OpenID Connect AI Auth Strategy를 참조하면, 그 IdP에서 발급된 유효한 토큰을 가진 모든 호출자가 전부 인증을 통과해요. 특정 AI Model, AI Agent, 또는 AI MCP Server에 대한 접근을 실제로 분리하는 건 access.acls예요.

Discovery 캐시

OIDC Auth Strategy에서 config.issuer를 설정하면, AI Gateway가 provider의 discovery metadata를 자동으로 가져와요. OIDC Auth Strategy는 이 metadata를 discovery cache 객체로 저장하고, 반복해서 가져오는 일을 피하려고 이 캐시를 사용해요. 이 캐시에는 discovery document 엔드포인트, JWKS 키, token 엔드포인트가 포함돼요.

검증에 issuer metadata가 필요할 때마다 AI Gateway는 discovery cache를 사용해요. 캐시는 다음과 같이 동작해요:

  • 캐시 TTL(time-to-live)은 config.cache_ttl이 관리하며, 기본값은 3600초예요.
  • 요청에 캐시에 없는 discovery 정보가 필요하면, 플러그인이 config.issuer의 값을 사용해 “rediscovery”를 시도해요. rediscovery가 한 번 일어나면 config.rediscovery_lifetime에 정의된 기간이 지나기 전까지는 추가 rediscovery 시도를 하지 않아요. 이 덕분에 identity provider에 과도한 요청이 가는 걸 막을 수 있죠.
  • discovery 데이터가 없어서 JWT를 검증할 수 없고, rediscovery 요청이 2xx가 아닌 상태 코드를 반환하면, 플러그인은 캐시에 남아 있는 충분한 discovery 정보를 사용해 fallback해요.

지원되는 flow와 grant

config.auth_methods로 어떤 flow를 활성화할지 설정해요. AI Gateway는 기본적으로 bearer와 client_credentials를 활성화해요. AI Gateway는 다음 우선순위대로 자격 증명을 찾아요:

  1. 세션 인증
  2. JWT access token 인증 (bearer)
  3. Introspection 인증
  4. User info 인증
  5. Refresh token grant
  6. Password grant
  7. Client credentials grant
  8. Authorization code flow

AI Gateway는 이 순서에서 처음 일치하는 항목에서 멈춰요. 이 우선순위는 AI Auth Strategy 아래에서 동일한 플러그인 엔진이 동작하기 때문에 AI Gateway의 OpenID Connect plugin이 사용하는 것과 같고, 고정되어 있어서 다시 설정할 수 없어요.

세션 인증

호출자가 다른 flow 중 하나를 통해 처음 인증하면, AI Gateway가 session cookie를 발급할 수 있어요. 그 후 호출자는 다시 인증하는 대신 이후 요청에서 그 cookie를 제시해요. 예를 들어 authorization code flow는 redirect login 액션을 사용할 때 세션 인증을 보여줘요.

다이어그램

 
sequenceDiagram
    autonumber
    participant client as Client 
(e.g. mobile app) participant kong as Gateway participant httpbin as Upstream
(upstream service,
e.g. httpbin) activate client activate kong client->>kong: Service with
session cookie deactivate client kong->>kong: load session cookie kong->>kong: verify session activate httpbin kong->>httpbin: request with
access token httpbin->>kong: response deactivate httpbin activate client kong->>client: response deactivate kong deactivate client

예시

kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_auth_strategies:
  - ref: session-auth
    ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
    display_name: Session Auth
    name: session-auth
    type: openid-connect
    config:
      issuer: https://dev-123456.okta.com
      client_id:
      - my-client-id
      client_secret:
      - !secret {source: !env 'CLIENT_SECRET'}
      auth_methods:
      - bearer
      - session
      consumer_claims:
      - - sub
      cache_tokens_salt: session-auth-cache-salt
EOF

{: data-test-step="block" }

JWT access token 인증 (bearer)

레거시 사정 때문에, stateless JWT access token 인증은 config.auth_methods에서 bearer라는 이름을 사용해요. AI Gateway는 IdP가 공개한 키로 토큰 서명을 검증하고, exp 같은 표준 claim을 검증해요.

다이어그램

 
sequenceDiagram
    autonumber
    participant client as Client 
(e.g. mobile app) participant kong as Gateway participant httpbin as Upstream
(upstream service,
e.g. httpbin) activate client activate kong client->>kong: Service with
access token deactivate client kong->>kong: load access token kong->>kong: verify signature kong->>kong: verify claims activate httpbin kong->>httpbin: request with
access token httpbin->>kong: response deactivate httpbin activate client kong->>client: response deactivate kong deactivate client

예시

kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_auth_strategies:
  - ref: bearer-token-auth
    ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
    display_name: Bearer Token Auth
    name: bearer-token-auth
    type: openid-connect
    config:
      issuer: https://dev-123456.okta.com
      client_id:
      - my-client-id
      client_secret:
      - !secret {source: !env 'CLIENT_SECRET'}
      auth_methods:
      - bearer
      consumer_claims:
      - - sub
      cache_tokens_salt: bearer-token-auth-cache-salt
EOF

{: data-test-step="block" }

Introspection 인증

bearer와 마찬가지로, introspection 인증도 AI Consumer가 이미 발급받은 토큰에 의존해요. 차이점은 AI Gateway가 IdP의 introspection 엔드포인트를 호출해서 토큰이 유효하고 활성 상태인지 확인한다는 것이고, 이 덕분에 IdP는 JWT 대신 opaque 토큰을 발급할 수 있어요.

다이어그램

 
sequenceDiagram
    autonumber
    participant client as Client 
(e.g. mobile app) participant kong as Gateway participant idp as IdP
(e.g. Keycloak) participant httpbin as Upstream
(upstream service,
e.g. httpbin) activate client activate kong client->>kong: Service with access token deactivate client kong->>kong: load access token activate idp kong->>idp: IdP/introspect with
client credentials and access token deactivate kong idp->>idp: authenticate client
and introspect access token activate kong idp->>kong: return introspection response deactivate idp kong->>kong: verify introspection response activate httpbin kong->>httpbin: request with
access token httpbin->>kong: response deactivate httpbin activate client kong->>client: response deactivate kong deactivate client

예제

kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_auth_strategies:
  - ref: introspection-auth
    ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
    display_name: Introspection Auth
    name: introspection-auth
    type: openid-connect
    config:
      issuer: https://dev-123456.okta.com
      client_id:
      - my-client-id
      client_secret:
      - !secret {source: !env 'CLIENT_SECRET'}
      auth_methods:
      - introspection
      consumer_claims:
      - - sub
      client_auth:
      - client_secret_post
      cache_tokens_salt: introspection-auth-cache-salt
EOF

{: data-test-step="block" }

참고: config.client_auth를 client_secret_post로 설정하면 IdP와의 연결을 테스트할 수 있어요. 하지만 프로덕션 환경에서는 더 안전한 인증 방식을 사용할 것을 권장해요. 지원되는 클라이언트 인증 방식 중 어떤 것이든 사용할 수 있어요.

사용자 정보 인증

사용자 정보 인증은 인트로스펙션 엔드포인트 대신 IdP의 표준 user info 엔드포인트를 통해 액세스 토큰을 검증해요. 대부분의 경우에는 인트로스펙션을 대신 사용하세요. 인트로스펙션은 토큰 자체를 검증하는 용도이고, user info는 토큰이 발급된 사용자에 대한 정보를 조회하는 용도예요.

다이어그램

 
sequenceDiagram
    autonumber
    participant client as Client 
(e.g. mobile app) participant kong as Gateway participant idp as IdP
(e.g. Keycloak) participant httpbin as Upstream
(upstream service,
e.g. httpbin) activate client activate kong client->>kong: Service with
access token deactivate client kong->>kong: load access token activate idp kong->>idp: IdP/userinfo
with access token deactivate kong idp->>idp: verify access token activate kong idp->>kong: return user info
response deactivate idp kong->>kong: verify response
status code (200) activate httpbin kong->>httpbin: request with access token httpbin->>kong: response deactivate httpbin activate client kong->>client: response deactivate kong deactivate client

예제

kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_auth_strategies:
  - ref: user-info-auth
    ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
    display_name: User Info Auth
    name: user-info-auth
    type: openid-connect
    config:
      issuer: https://dev-123456.okta.com
      client_id:
      - my-client-id
      client_secret:
      - !secret {source: !env 'CLIENT_SECRET'}
      auth_methods:
      - userinfo
      consumer_claims:
      - - sub
      client_auth:
      - client_secret_post
      cache_tokens_salt: user-info-auth-cache-salt
EOF

{: data-test-step="block" }

참고: config.client_auth를 client_secret_post로 설정하면 IdP와의 연결을 테스트할 수 있어요. 하지만 프로덕션 환경에서는 더 안전한 인증 방식을 사용할 것을 권장해요. 지원되는 클라이언트 인증 방식 중 어떤 것이든 사용할 수 있어요.

리프레시 토큰 그랜트

리프레시 토큰 그랜트는 AI Consumer가 이미 리프레시 토큰을 갖고 있을 때 사용할 수 있어요. IdP는 일반적으로 리프레시 토큰 그랜트가 처음에 토큰을 발급받은 것과 동일한 클라이언트로만 실행되도록 허용해요. 클라이언트가 일치하지 않으면 그랜트가 실패할 수 있어요.

다이어그램

 
sequenceDiagram
    autonumber
    participant client as Client 
(e.g. mobile app) participant kong as Gateway participant idp as IdP
(e.g. Keycloak) participant httpbin as Upstream
(upstream service,
e.g. httpbin) activate client activate kong client->>kong: Service with
refresh token deactivate client kong->>kong: load refresh token activate idp kong->>idp: IdP/token with
client credentials and
refresh token deactivate kong idp->>idp: authenticate client and
verify refresh token activate kong idp->>kong: return tokens deactivate idp kong->>kong: verify tokens activate httpbin kong->>httpbin: request with access token httpbin->>kong: response deactivate httpbin activate client kong->>client: response deactivate kong deactivate client

예제

kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_auth_strategies:
  - ref: refresh-token-auth
    ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
    display_name: Refresh Token Auth
    name: refresh-token-auth
    type: openid-connect
    config:
      issuer: https://dev-123456.okta.com
      client_id:
      - my-client-id
      client_secret:
      - !secret {source: !env 'CLIENT_SECRET'}
      auth_methods:
      - refresh_token
      consumer_claims:
      - - sub
      client_auth:
      - client_secret_post
      cache_tokens_salt: refresh-token-auth-cache-salt
EOF

{: data-test-step="block" }

참고: config.client_auth를 client_secret_post로 설정하면 IdP와의 연결을 테스트할 수 있어요. 하지만 프로덕션 환경에서는 더 안전한 인증 방식을 사용할 것을 권장해요. 지원되는 클라이언트 인증 방식 중 어떤 것이든 사용할 수 있어요.

패스워드 그랜트

패스워드 그랜트는 레거시 인증 그랜트예요. 이 방식은 예를 들어 비밀번호가 제3자와 공유되기 때문에, 인가 코드 플로우보다 엔드 유저를 인증하기에 덜 안전해요.

다이어그램

 
sequenceDiagram
    autonumber
    participant client as Client 
(e.g. mobile app) participant kong as Gateway participant idp as IdP
(e.g. Keycloak) participant httpbin as Upstream
(upstream service,
e.g. httpbin) activate client activate kong client->>kong: Service with
basic authentication deactivate client kong->>kong: load
basic authentication
credentials activate idp kong->>idp: IdP/token with
client credentials and
password grant deactivate kong idp->>idp: authenticate client and
verify password grant activate kong idp->>kong: return tokens deactivate idp kong->>kong: verify tokens activate httpbin kong->>httpbin: request with access token httpbin->>kong: response deactivate httpbin activate client kong->>client: response deactivate kong deactivate client

예제

kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_auth_strategies:
  - ref: password-auth
    ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
    display_name: Password Auth
    name: password-auth
    type: openid-connect
    config:
      issuer: https://dev-123456.okta.com
      client_id:
      - my-client-id
      client_secret:
      - !secret {source: !env 'CLIENT_SECRET'}
      auth_methods:
      - password
      consumer_claims:
      - - sub
      password_param_type:
      - header
      cache_tokens_salt: password-auth-cache-salt
EOF

{: data-test-step="block" }

클라이언트 자격 증명 그랜트

AI Gateway는 AI Consumer가 전달하는 자격 증명을, 자체 인증을 시도하지 않고 IdP의 토큰 엔드포인트로 직접 전달해요.

다이어그램

 
sequenceDiagram
    autonumber
    participant client as Client 
(e.g. mobile app) participant kong as Gateway participant idp as IdP
(e.g. Keycloak) participant httpbin as Upstream
(upstream service,
e.g. httpbin) activate client activate kong client->>kong: Service with
basic authentication deactivate client kong->>kong: load basic
authentication credentials activate idp kong->>idp: IdP/token
with client credentials deactivate kong idp->>idp: authenticate client activate kong idp->>kong: return tokens deactivate idp kong->>kong: verify tokens activate httpbin kong->>httpbin: request with access token httpbin->>kong: response deactivate httpbin activate client kong->>client: response deactivate kong deactivate client

예제

kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_auth_strategies:
  - ref: client-credentials-auth
    ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
    display_name: Client Credentials Auth
    name: client-credentials-auth
    type: openid-connect
    config:
      issuer: https://dev-123456.okta.com
      client_id:
      - my-client-id
      client_secret:
      - !secret {source: !env 'CLIENT_SECRET'}
      auth_methods:
      - client_credentials
      consumer_claims:
      - - sub
      client_credentials_param_type:
      - header
      client_auth:
      - client_secret_post
      cache_tokens_salt: client-credentials-auth-cache-salt
EOF

{: data-test-step="block" }

참고: config.client_auth를 client_secret_post로 설정하면 IdP와의 연결을 테스트할 수 있어요. 하지만 프로덕션 환경에서는 더 안전한 인증 방식을 사용할 것을 권장해요. 지원되는 클라이언트 인증 방식 중 어떤 것이든 사용할 수 있어요.

인가 코드 플로우

인가 코드 플로우는 세션 쿠키 발급을 포함하는 three-legged OAuth/OpenID Connect 플로우예요. 아래 시퀀스 다이어그램은 이 사용 시나리오에서 세션 쿠키 사용을 포함해, 참여자들과 그들 간의 상호작용을 설명해요.

다이어그램

 
sequenceDiagram
    autonumber
    participant client as Client 
(e.g. mobile app) participant kong as Gateway participant idp as IdP
(e.g. Keycloak) participant httpbin as Upstream
(upstream service,
e.g. httpbin) activate client activate kong client->>kong: HTTP request kong->>client: Redirect mobile app to IDP deactivate kong activate idp client->>idp: Request access and authentication
with client parameter Note left of idp: /auth
response_type=code,
scope=openid idp->>client: Login (ask for consent) client->>idp: /auth with user credentials (grant consent) idp->>client: Return authorization code and redirect Note left of idp: short-lived authcode activate kong client->>kong: HTTP redirect with authorization code deactivate client kong->>kong: Verify authorization code flow kong->>idp: Request ID token, access token, and refresh token Note left of idp: /token
client_id:client_secret
authcode idp->>idp: Authenticate client (Kong)
and validate authcode idp->>kong: Returns tokens Note left of idp: ID token, access token, and refresh token deactivate idp kong->>kong: Validate tokens Note right of kong: Cryptographic
signature validation,
expiry check
(OIDC Standard JWT validation) activate client kong->>client: Redirect with session cookie
having session ID (SID) Note left of kong: sid: cryptorandom bytes
(128 bits)
& HMAC protected client->>kong: Authenticated request with session cookie deactivate client kong->>kong: Verify session cookie Note right of kong: Retrieve encrypted tokens
from session store (redis) activate httpbin kong->>httpbin: Backend service request with tokens Note right of idp: Access token and ID token httpbin->>kong: Backend service response deactivate httpbin activate client kong->>client: HTTP response deactivate kong deactivate client

예제

kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_auth_strategies:
  - ref: auth-code-auth
    ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
    display_name: Auth Code Auth
    name: auth-code-auth
    type: openid-connect
    config:
      issuer: https://dev-123456.okta.com
      client_id:
      - my-client-id
      client_secret:
      - !secret {source: !env 'CLIENT_SECRET'}
      client_auth:
      - client_secret_post
      auth_methods:
      - authorization_code
      - session
      response_mode: form_post
      preserve_query_args: true
      login_action: redirect
      login_tokens:
      redirect_uri:
      - https://my-app.example.com/callback
      consumer_claims:
      - - sub
      cache_tokens_salt: auth-code-auth-cache-salt
EOF

{: data-test-step="block" }

참고: config.client_auth를 client_secret_post로 설정하면 IdP와의 연결을 테스트할 수 있어요. 하지만 프로덕션 환경에서는 더 안전한 인증 방식을 사용할 것을 권장해요. 지원되는 클라이언트 인증 방식 중 어떤 것이든 사용할 수 있어요.

PKCE를 사용하는 경우, RFC 8414에 따라 IdP는 /.well-known/openid-configuration 디스커버리 응답에 code_challenge_methods_supported를 포함해야 해요. 그렇지 않으면 AI Gateway는 PKCE code_challenge 파라미터를 전송하지 않아요.

권한 부여

access.acls 외에도(동작 방식 참고), OpenID Connect AI Auth Strategy는 클레임 기반 권한 부여를 지원해요. 클레임 기반 권한 부여는 옵션 쌍을 사용해서 권한 부여 중 클레임 검증을 관리해요. 이 쌍은 다음 중 하나예요:

  • config.scopes_claim 및 config.scopes_required
  • config.audience_claim 및 config.audience_required
  • config.groups_claim 및 config.groups_required
  • config.roles_claim 및 config.roles_required

각 파라미터 쌍에서 *_claim 파라미터는 소스를 가리키고, *_required 파라미터는 검증 대상이 되는 클레임 값들의 집합을 정의해요.

클레임 기반 권한 부여는 다음 규칙을 따라요:

  • 한 번에 최대 4개의 클레임을 검증할 수 있어요
  • 클레임 이름을 찾기 위해 배열이나 객체를 탐색할 수 있어요
  • OR과 AND 로직을 사용해서 동일한 클레임의 여러 값을 검증할 수 있어요

클레임 타입과 필수 클레임 내용은 모두 문자열 요소로 이루어진 배열을 받아요.

클레임 타입

클레임 타입(예: config.groups_claim)의 경우, 배열은 중첩 순서대로 나열된 JSON 객체들의 목록이에요. AI Gateway는 배열에 있는 항목들의 순서를 사용해서 JSON 페이로드에서 데이터를 찾아요.

클레임의 값은 다음 중 하나일 수 있어요:

  • 공백으로 구분된 문자열 (스코프 클레임에서 흔함)
  • 문자열의 JSON 배열 (그룹 클레임에서 흔함)
  • 문자열 같은 단순 값

예를 들어, groups가 user 안에 중첩되어 있는 다음 샘플 페이로드를 보세요:

{
    "user": {
        "name": "alex",
        "groups": [
            "employee",
            "marketing"
        ]
    }
}

이 경우 config.groups_claim을 사용해서 필요한 그룹들까지 탐색하세요. 여기서 groups는 그룹 목록을 담고 있는 JSON 객체예요:

config:
  groups_claim:
  - user
  - groups

클레임 요구 사항

config.*_required 파라미터(예: config.groups_required)는 논리적인 AND/OR 방식의 검사를 허용하는 배열이에요:

  • AND: 공백으로 구분된 값이에요. 이 클레임에는 employee와 marketing이 둘 다 있어야 해요:

    config:
      groups_required:
      - employee marketing
    
  • OR: 별개의 배열 인덱스에 있는 값이에요. 이 클레임에는 employee 또는 marketing이 있어야 해요:

    config:
      groups_required:
      - employee
      - marketing
    

이 기능은 access.acls와는 독립적으로 동작해요. access.acls는 이미 확인된 AI Consumer 신원을 특정 엔티티를 대상으로 권한 부여하는 기능이에요.

클레임 검사가 실패하면, 다른 인증 실패와 마찬가지로 요청은 익명 AI Consumer로 넘어가고, 호출자는 401 Unauthorized를 받게 돼요.

클라이언트 인증

config.client_auth는 상호 TLS(mTLS) 클라이언트 인증을 포함해서, AI Gateway가 IdP에 스스로를 인증하는 방식을 선택해요.

참고: config.client_auth를 client_secret_post로 설정하면 IdP와의 연결을 테스트할 수 있지만, 프로덕션에서는 더 안전한 인증 방법을 사용하는 것을 권장해요. 지원되는 클라이언트 인증 방법 중 하나를 사용할 수 있어요.

상호 TLS 클라이언트 인증

OpenID Connect 인증 전략은 IdP와의 상호 TLS(mTLS) 클라이언트 인증을 지원해요. mTLS 인증이 활성화되면, AI Gateway는 구성된 클라이언트 인증서를 사용해서 IdP와 mTLS 연결을 설정해요. 다음 IdP 엔드포인트와 그에 해당하는 플로우에서 mTLS 클라이언트 인증을 사용할 수 있어요:

이 모든 엔드포인트와 지원되는 플로우에서, 인증 전략은 IdP와 통신할 때(예: 토큰 엔드포인트에서 토큰을 가져올 때) mTLS 클라이언트 인증을 인증 방법으로 사용해요.

고급 OpenID Connect 플러그인 기능

다음 기능들은 Kong Gateway의 OpenID Connect 플러그인에 있는 것으로, 고급 사용 사례를 위해 OpenID Connect AI Auth Strategy의 config 객체가 이를 플러그인으로 전달해요.

금융 등급 API(FAPI)

AI Gateway는 고가치의 민감한 데이터를 노출하는 API를 보호하기 위한 FAPI 표준의 다양한 기능을 지원해요.

푸시된 권한 부여 요청(PAR)

설명: PAR이 활성화되면, AI Gateway(OAuth 클라이언트 역할)가 권한 부여 요청의 페이로드를 IdP로 보내요. 그 결과로 request_uri 값을 얻어요. 클라이언트는 권한 부여 요청 페이로드 데이터를 얻기 위한 참조로서, 권한 부여 엔드포인트를 호출할 때 이 값을 사용해요.

PAR을 활성화하려면 config.pushed_authorization_request_endpoint를 사용하세요.

JWT로 보호된 권한 부여 요청(JAR)

설명: JAR이 활성화되면, 권한 부여 엔드포인트로 요청을 보낼 때 AI Gateway가 쿼리 문자열 대신 JSON Web Token(JWT)에 요청 파라미터를 담아 제공해요. 이를 통해 요청 데이터를 JSON Web Signature(JWS)로 서명할 수 있어요.

JAR을 활성화하려면 config.require_signed_request_object를 사용하세요.

JWT로 보호된 권한 부여 응답 모드(JARM)

설명: | JARM이 활성화되면, AI Gateway는 권한 부여 서버에게 권한 부여 응답 파라미터를 JWT로 인코딩해서 반환하도록 요청해요. 이를 통해 응답 데이터를 JSON Web Signature(JWS)로 서명할 수 있어요.

JARM을 활성화하려면 config.response_mode를 query.jwt, form_post.jwt, fragment.jwt, jwt 중 하나로 설정하세요.

인증서 바인딩 액세스 토큰

설명: | 인증서 바인딩 액세스 토큰은 토큰을 클라이언트에 바인딩할 수 있게 해줘요. 이를 통해 발신자가 보호된 리소스에 접근하기 위해 토큰을 사용할 권한이 있는지 검증함으로써 토큰의 진정성을 보장해요.

인증서 바인딩 액세스 토큰을 활성화하려면 config.proof_of_possession_mtls를 strict로 설정하고, config.client_id를 클라이언트 인증서에 바인딩된 클라이언트로 설정하세요.

인증서 바인딩 액세스 토큰을 사용한 상호 TLS(mTLS) 클라이언트 인증

설명: | mTLS 클라이언트 인증이 활성화되면, AI Gateway는 구성된 X.509 인증서를 클라이언트 자격 증명으로 사용해서 IdP와 mTLS 연결을 설정해요.

권한 부여 서버가 발급된 액세스 토큰과 클라이언트 인증서를 바인딩하도록 구성된 경우, AI Gateway는 mTLS 소유 증명(proof of possession)을 사용해서 액세스 토큰을 검증할 수 있어요.

mTLS 인증을 활성화하려면 config.client_auth를 tls_client_auth로 설정하고, config.tls_client_auth_cert_id에 인증서를 제공하세요.

소유 증명 시연(DPoP)

설명: | DPoP(Demonstrating Proof of Possession)는 발신자가 OAuth 액세스 토큰과 리프레시 토큰을 소유하고 있음을 증명하기 위한 애플리케이션 수준의 메커니즘이에요. DPoP를 사용하면 클라이언트가 헤더를 사용해서 토큰과 연관된 공개/개인 키 쌍의 소유를 증명할 수 있어요. 이 헤더에는 연관된 액세스 토큰에 대한 참조가 포함된 서명된 JWT가 담겨 있어요.

DPoP가 활성화되면, AI Gateway는 요청의 DPoP 헤더를 검증해서 발신자가 액세스 토큰을 사용할 권한이 있는지 확인해요.

DPoP를 활성화하려면 config.proof_of_possession_dpop를 strict로 설정하세요.

인증서 바인딩 액세스 토큰

OAuth의 주요 취약점 중 하나는 베어러 토큰이에요. OAuth에서는 유효한 베어러 토큰을 제시하는 것만으로 리소스에 접근하기에 충분한 증명이 돼요. 토큰을 제시하는 클라이언트가 토큰이 발급된 정당한 사용자로 검증되지 않기 때문에 문제가 생길 수 있어요.

인증서 바인딩 액세스 토큰은 토큰을 클라이언트에 바인딩해서 이 문제를 해결해요. 발신자가 특정 토큰을 사용해서 보호된 리소스에 접근할 권한이 있다는 증명을 요구하기 때문에 토큰의 정당성이 보장돼요.

인증서 바인딩 액세스 토큰은 다음 인증 방법에서 지원돼요:

세션 인증은 다른 지원되는 인증 방법 중 하나와 함께 사용할 때만 인증서 바인딩 액세스 토큰과 호환돼요:

  • config.proof_of_possession_auth_methods_validation이 false로 설정되어 있고 호환되지 않는 다른 방법이 활성화되어 있으며 유효한 세션이 발견된 경우, AI Gateway는 그 세션이 원래 호환되는 방법 중 하나를 사용해서 생성된 경우에만 소유 증명 검증을 수행해요.
  • session 인증 방법으로 여러 OpenID Connect 인증 전략 인스턴스를 구성하는 경우, 추가 보안을 위해 각 인스턴스에 서로 다른 config.session_secret 값을 구성하세요. 이렇게 하면 세션이 인증 전략 인스턴스 간에 공유되어 소유 증명 검증을 우회하는 일을 막을 수 있어요.

인증서 바인딩 액세스 토큰을 활성화하려면:

  • 사용 중인 IdP가 OAuth 2.0 상호 TLS 인증서 바인딩 액세스 토큰을 생성하도록 설정되어 있는지 확인하세요.
  • config.proof_of_possession_mtls를 사용해서, 요청에서 제공된 클라이언트 인증서와의 바인딩을 확인함으로써 제공된 액세스 토큰이 해당 클라이언트의 것인지 검증하세요.

다음은 인증서 바인딩 액세스 토큰 구성 예시예요:

kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_auth_strategies:
  - ref: cert-bound-auth
    ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
    display_name: Cert-Bound Access Tokens Auth
    name: cert-bound-auth
    type: openid-connect
    config:
      issuer: https://dev-123456.okta.com
      client_id:
      - my-client-id
      client_secret:
      - !secret {source: !env 'CLIENT_SECRET'}
      auth_methods:
      - bearer
      proof_of_possession_mtls: strict
      consumer_claims:
      - - sub
      cache_tokens_salt: cert-bound-auth-cache-salt
EOF

{: data-test-step="block" }

DPoP(Demonstrating Proof-of-Possession, 소유 증명 시연)

DPoP(Demonstrating Proof-of-Possession, 소유 증명 시연)는 인증서 바인딩 액세스 토큰을 사용한 상호 TLS 클라이언트 인증의 대안 기술이에요. 토큰을 mTLS 클라이언트 인증서에 바인딩하는 mTLS와 달리, DPoP는 토큰을 클라이언트가 제공한 JSON Web Key(JWK)에 바인딩해요.

 
sequenceDiagram
    autonumber
    participant client as Client 
(e.g. mobile app) participant kong as Gateway participant upstream as Upstream
(backend service,
e.g. httpbin) participant idp as Authentication Server
(e.g. Keycloak) activate client client->>client: generate key pair client->>idp: POST /oauth2/token
DPoP:$PROOF deactivate client activate idp idp-->>client: DPoP bound access token ($AT) activate client deactivate idp client->>kong: GET https://example.com/resource
Authorization: DPoP $AT
DPoP: $PROOF activate kong deactivate client kong->>kong: validate $AT and $PROOF kong->>upstream: proxied request
GET https://example.com/resource
Authorization: Bearer $AT deactivate kong activate upstream upstream-->>kong: upstream response deactivate upstream activate kong kong-->>client: response deactivate kong

DPoP는 mTLS 없이, 심지어 일반 HTTP에서도 사용할 수 있어요. 다만 보안을 강화하려면 HTTPS가 권장돼요.

DPoP proof 검증이 활성화되면 AI Gateway는 DPoP 헤더를 제거하고 토큰 타입을 dpop에서 bearer로 변경해요. 이로써 요청은 사실상 일반적인 bearer 토큰 방식으로 다운그레이드되고, DPoP를 지원하지 않는 업스트림도 키 바인딩 메커니즘의 보호를 잃지 않은 채 DPoP 토큰으로 동작할 수 있어요.

DPoP는 다음 인증 방식과 호환돼요:

세션 인증은 다른 지원 인증 방식 중 하나와 함께 사용할 때에만 DPoP와 호환돼요. session 인증 방식을 사용하는 OpenID Connect auth strategy 인스턴스를 여러 개 구성한다면, 추가 보안을 위해 각 인스턴스에 서로 다른 config.session_secret 값을 설정하세요. 이렇게 하면 세션이 auth strategy 인스턴스 간에 공유되어 소유 증명 검증을 우회하는 일을 막을 수 있어요.

DPoP를 활성화하려면:

  • 사용 중인 IdP에서 DPoP가 활성화되어 있는지 확인하세요.
  • 요청에 제공된 JWT와의 연관성을 확인해서 제공된 액세스 토큰이 클라이언트에 바인딩되어 있는지 검증하려면 config.proof_of_possession_dpop을 사용하세요.

다음은 DPoP 설정 예시예요:

kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_auth_strategies:
  - ref: dpop-auth
    ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
    display_name: DPoP Auth
    name: dpop-auth
    type: openid-connect
    config:
      issuer: https://dev-123456.okta.com
      client_id:
      - my-client-id
      client_secret:
      - !secret {source: !env 'CLIENT_SECRET'}
      auth_methods:
      - bearer
      proof_of_possession_dpop: strict
      consumer_claims:
      - - sub
      cache_tokens_salt: dpop-auth-cache-salt
EOF

{: data-test-step="block" }

다중 IdP 지원

여러분의 API가 서로 다른 identity provider로 인증하는 클라이언트를 서비스한다면, OIDC auth strategy가 게이트웨이 레이어에서 여러 issuer의 토큰을 검증해 주기 때문에 백엔드에는 IdP별 로직이 필요 없어요.

다음 방법 중 하나로 구현할 수 있어요:

  • 신뢰하는 issuer 레지스트리: config.issuers_allowed와 config.extra_jwks_uris를 사용해 신뢰하는 issuer 목록과 각각의 JWKS 엔드포인트로 OIDC auth strategy를 구성하세요. AI Gateway는 들어오는 토큰을 적절한 퍼블릭 키로 검증한 후 백엔드로 그대로 전달해요. 토큰 형식이 여러 IdP에서 일관될 때 가장 잘 동작해요.

  • 토큰 교환: config.token_exchange를 사용해 들어오는 토큰을 신뢰하는 한 issuer의 정규(canonical) 토큰으로 교환하도록 OIDC auth strategy를 구성하세요. 클라이언트가 어떤 IdP를 사용했는지와 관계없이 백엔드는 항상 단일 issuer의 토큰을 받아요. 백엔드가 하나의 issuer만 신뢰해야 하거나, 여러 IdP에 걸쳐 scope와 claim을 정규화해야 할 때 가장 잘 동작해요.

토큰 교환

OAuth 2.0 Token Exchange(RFC 8693)는 기존 보안 토큰을 새 토큰으로 교환할 수 있게 해주는 OAuth 2.0 프레임워크의 확장이에요. 이 RFC는 클라이언트가 authorization server와 상호작용해 토큰을 새 토큰으로 교환할 수 있는 시나리오를 지원하기 위한 프로토콜 접근 방식을 정의해요. 이는 마이크로서비스나 크로스 도메인 연합(federation) 같은 복잡한 환경에서 특히 유용해요.

참고: OIDC auth strategy로 교환할 수 있는 것은 액세스 토큰뿐이에요. access.metadata를 설정하는 AI MCP Server에서는 토큰 교환이 지원되지 않아요.

토큰 교환을 사용하는 이유

토큰 교환은 여러 중요한 사용 사례에서 활용할 수 있어요:

  • 다운스코핑(Downscoping): 서비스가 강력한 토큰을 받지만, 업스트림 서비스를 호출하는 데는 그 권한 중 일부만 필요해요. 최소 권한 원칙(Principle of Least Privilege)을 지키기 위해 강력한 토큰을 더 적은 scope를 가진 토큰으로 교환해요.
  • 내부 토큰 vs. 외부 토큰: 외부 불투명(opaque) 토큰이나 서드파티 토큰(예: SAML assertion)을 마이크로서비스가 이해할 수 있는 내부 JWT로 변환해요.
  • 가장(Impersonation)과 위임(Delegation): 서비스가 사용자를 대신해 동작할 수 있게 해줘요. 예를 들어, 프론트엔드 서비스는 백엔드 서비스를 호출하기 위해 자신의 토큰을 특정 scope를 가진 새 토큰으로 교환해야 해요.
  • 프라이버시: 업스트림 서비스로 전달하기 전에 토큰에서 민감한 사용자 정보를 제거해요.

토큰 교환은 새 토큰 생성을 허용하기 때문에 신뢰 모델이 매우 중요해요. 권한 상승(privilege escalation) 같은 보안 결함을 방지하려면, 신뢰 모델이 어떤 클라이언트가 토큰을 교환할 수 있는지, 그리고 어떤 scope로 상승하거나 다운그레이드하는 것이 허용되는지 엄격하게 정의해야 해요.

토큰 교환의 동작 방식

일반적인 OAuth 플로우에서는 리소스에 접근하기 위해 토큰을 얻어요. 하지만 토큰 교환에서는 클라이언트가 이미 토큰("subject token")을 가지고 있어요. AI Gateway는 들어오는 토큰 중 어떤 것이 교환 대상이 될 수 있는지 판단하고, 자체 클라이언트 자격 증명을 사용해 토큰 교환을 진행해요. subject token은 authorization server에 제출되어, 리소스에 접근하기에 더 적합한 다른 토큰("requested token")을 받는 데 사용돼요.

 
sequenceDiagram
    participant C as Client
(e.g. mobile app) participant K as Gateway participant A as Authorization server
(e.g. Keycloak) participant U as Upstream
(backend service,
e.g. httpbin) C->>K: Request with subject token activate K note over K: Validate subject token
(iss, exp, nbf) K->>A: Token exchange request activate A A-->>K: Exchanged access token deactivate A K->>K: Validate exchanged token K->>U: Proxy request with exchanged token activate U U-->>K: Response deactivate U K-->>C: Response deactivate K

교환을 트리거하기 전에, OIDC auth strategy는 수신되는 토큰에 대해 다음과 같은 검사를 수행해요:

  1. 수신되는 subject token이 다음 기준을 충족하는지 확인해요:
  • 발급자(iss 클레임)가 구성된 신뢰할 수 있는 발급자(subject_token_issuers)와 일치해요.
  • 토큰이 만료되지 않았어요(exp 클레임).
  • 토큰이 지정 시간 이전에 사용되지 않았어요(nbf 클레임).
  1. subject_token_issuer와 target_issuer가 다르면 토큰 교환이 트리거돼요.
  2. subject_token_issuer와 target_issuer가 같으면, 구성된 조건을 평가해서 토큰 교환을 트리거할지 여부를 결정해요.
  3. AI Gateway는 자체 client credentials를 사용해 교환을 트리거해요.

이후 OIDC auth strategy는 교환된 토큰을 나머지 플로우를 통해 계속 처리해요.

사용 사례에 따라, AI Gateway는 최초 subject token을 발급한 동일한 authorization server와 토큰을 교환하거나, 서로 다른 authorization server 간에 토큰을 교환할 수 있어요.

주요 용어

토큰 교환 플로우에서는 다음 용어를 사용해요:

  • Subject token: 교환 대상인 신원/권한을 나타내는 입력 토큰이에요.
  • Subject token issuer: 최초 토큰(subject token)을 발급한 authorization server예요.
  • Target issuer: 리소스(API/서비스)를 보호하는 authorization server예요.
  • Conditions: 토큰 교환을 트리거하는 조건이에요. Conditions는 scopes와 audience 두 클레임의 존재 여부를 확인해요.

다음은 토큰 교환 구성의 예시예요. 이 구성은 요청을 업스트림으로 프록시하기 전에, https://keycloak.example.com에서 발급된 토큰을 AI Auth Strategy 자체 발급자인 https://dev-123456.okta.com의 토큰으로 교환해요:

kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_auth_strategies:
  - ref: token-exchange-auth
    ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
    display_name: Token Exchange Auth
    name: token-exchange-auth
    type: openid-connect
    config:
      issuer: https://dev-123456.okta.com
      client_id:
      - my-client-id
      client_secret:
      - !secret {source: !env 'CLIENT_SECRET'}
      client_auth:
      - client_secret_post
      auth_methods:
      - bearer
      token_exchange:
        subject_token_issuers:
        - issuer: https://keycloak.example.com
        request:
          empty_audience: false
          scopes:
          empty_scopes: false
          audience:
      cache_tokens_salt: token-exchange-auth-cache-salt
EOF

{: data-test-step="block" }

Redis에서 클라우드 인증 사용하기

session 또는 authorization code 플로우의 세션을 저장하기 위해 config.session_storage를 redis로 설정했다면, 클라우드 프로바이더를 사용해 Redis에 인증할 수 있어요. 이를 통해 정적 비밀번호에 의존하지 않고도 자격 증명을 순환할 수 있어요.

지원되는 프로바이더는 다음과 같아요:

  • AWS ElastiCache
  • Azure Managed Redis
  • Google Cloud Memorystore (Valkey 포함 또는 미포함)

각 프로바이더는 인스턴스 구성과 클러스터 구성도 지원해요.

AWS 인스턴스

필요한 항목은 다음과 같아요:

  • Valkey 7.2 이상 또는 ElastiCache for Redis OSS 버전 7.0 이상의 AWS ElastiCache 인스턴스에서 실행 중인 Redis 인스턴스
  • ElastiCache 사용자가 "Authentication mode"를 "IAM"으로 설정해야 함
  • ElastiCache에 연결하는 데 사용되는 IAM 사용자/IAM 역할에 다음 정책이 할당되어 있어야 해요:
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "elasticache:Connect"
                ],
                "Resource": [
                    "arn:aws:elasticache:ARN_OF_THE_ELASTICACHE",
                    "arn:aws:elasticache:ARN_OF_THE_ELASTICACHE_USER"
                ]
            }
        ]
    }
    

Redis로 클라우드 인증을 구성하려면, Policy 구성에 다음 파라미터를 추가하세요:

config:
  session_storage: redis
  redis:
    host: $INSTANCE_ADDRESS
    username: $INSTANCE_USERNAME
    port: 6379
    cloud_authentication:
      auth_provider: aws
      aws_cache_name: $AWS_CACHE_NAME
      aws_is_serverless: false
      aws_region: $AWS_REGION
      aws_access_key_id: $AWS_ACCESS_KEY_ID
      aws_secret_access_key: $AWS_ACCESS_SECRET_KEY

다음 항목을 실제 값으로 바꾸세요:

  • $INSTANCE_ADDRESS: ElastiCache 인스턴스 주소.
  • $INSTANCE_USERNAME: IAM Auth mode가 구성된 ElastiCache 사용자 이름.
  • $AWS_CACHE_NAME: AWS ElastiCache 인스턴스의 이름.
  • $AWS_REGION: AWS ElastiCache 인스턴스의 리전.
  • $AWS_ACCESS_KEY_ID: (선택 사항) AWS 액세스 키 ID.
  • $AWS_ACCESS_SECRET_KEY: (선택 사항) AWS 시크릿 액세스 키.

AWS 클러스터

다음이 필요해요:

  • Valkey 7.2 이상 또는 ElastiCache for Redis OSS 버전 7.0 이상 기반의 AWS ElastiCache 클러스터에서 실행 중인 Redis 인스턴스
  • ElastiCache 사용자가 "Authentication mode"를 "IAM"으로 설정해야 함
  • ElastiCache에 연결하는 데 사용하는 IAM 사용자/IAM 역할에 다음 정책이 할당되어 있어야 해요:
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "elasticache:Connect"
                ],
                "Resource": [
                    "arn:aws:elasticache:ARN_OF_THE_ELASTICACHE",
                    "arn:aws:elasticache:ARN_OF_THE_ELASTICACHE_USER"
                ]
            }
        ]
    }
    

Redis 클라우드 인증을 구성하려면 Policy 구성에 다음 파라미터를 추가하세요:

config:
  session_storage: redis
  redis:
    cluster_nodes:
    - ip: $CLUSTER_ADDRESS
      port: 6379
    username: $CLUSTER_USERNAME
    port: 6379
    cloud_authentication:
      auth_provider: aws
      aws_cache_name: $AWS_CACHE_NAME
      aws_is_serverless: false
      aws_region: $AWS_REGION
      aws_access_key_id: $AWS_ACCESS_KEY_ID
      aws_secret_access_key: $AWS_ACCESS_SECRET_KEY

다음을 실제 값으로 바꾸세요:

  • $CLUSTER_ADDRESS: ElastiCache 클러스터 주소예요.
  • $CLUSTER_USERNAME: IAM Auth 모드가 구성된 ElastiCache 사용자 이름이에요.
  • $AWS_CACHE_NAME: AWS ElastiCache 클러스터의 이름이에요.
  • $AWS_REGION: AWS ElastiCache 클러스터의 리전이에요.
  • $AWS_ACCESS_KEY_ID: (선택 사항) AWS 액세스 키 ID예요.
  • $AWS_ACCESS_SECRET_KEY: (선택 사항) AWS 시크릿 액세스 키예요.

Azure 인스턴스

다음이 필요해요:

Redis 클라우드 인증을 구성하려면 Policy 구성에 다음 파라미터를 추가하세요:

config:
  session_storage: redis
  redis:
    host: $INSTANCE_ADDRESS
    username: $INSTANCE_USERNAME
    port: 10000
    cloud_authentication:
      auth_provider: azure
      azure_client_id: $AZURE_CLIENT_ID
      azure_client_secret: $AZURE_CLIENT_SECRET
      azure_tenant_id: $AZURE_TENANT_ID

다음을 실제 값으로 바꾸세요:

  • $INSTANCE_ADDRESS: Azure Managed Redis 인스턴스 주소예요.
  • $INSTANCE_USERNAME: 필수 액세스 권한이 있는 Principal/Identity의 오브젝트(프린시펄) ID예요.
  • $AZURE_CLIENT_ID: Principal/Identity의 클라이언트 ID예요.
  • $AZURE_CLIENT_SECRET: (선택 사항) Principal/Identity의 클라이언트 시크릿이에요.
  • $AZURE_TENANT_ID: (선택 사항) Principal/Identity의 테넌트 ID예요.

Azure 클러스터

다음이 필요해요:

Redis 클라우드 인증을 구성하려면 Policy 구성에 다음 파라미터를 추가하세요:

config:
  session_storage: redis
  redis:
    cluster_nodes:
    - ip: $CLUSTER_ADDRESS
      port: 10000
    username: $CLUSTER_USERNAME
    port: 10000
    cloud_authentication:
      auth_provider: azure
      azure_client_id: $AZURE_CLIENT_ID
      azure_client_secret: $AZURE_CLIENT_SECRET
      azure_tenant_id: $AZURE_TENANT_ID

다음을 실제 값으로 바꾸세요:

  • $CLUSTER_ADDRESS: Azure Managed Redis 클러스터 주소예요.
  • $CLUSTER_USERNAME: 필수 액세스 권한이 있는 Principal/Identity의 오브젝트(프린시펄) ID예요.
  • $AZURE_CLIENT_ID: Principal/Identity의 클라이언트 ID예요.
  • $AZURE_CLIENT_SECRET: (선택 사항) Principal/Identity의 클라이언트 시크릿이에요.
  • $AZURE_TENANT_ID: (선택 사항) Principal/Identity의 테넌트 ID예요.

GCP 인스턴스

다음이 필요해요:

Redis 클라우드 인증을 구성하려면 Policy 구성에 다음 파라미터를 추가하세요:

config:
  session_storage: redis
  redis:
    host: $INSTANCE_ADDRESS
    port: 6379
    cloud_authentication:
      auth_provider: gcp
      gcp_service_account_json: $GCP_SERVICE_ACCOUNT

다음을 실제 값으로 바꾸세요:

  • $INSTANCE_ADDRESS: Memorystore 인스턴스 주소예요.
  • $GCP_SERVICE_ACCOUNT: (선택 사항) GCP 서비스 계정 JSON이에요.

GCP 클러스터

다음이 필요해요:

Redis 클라우드 인증을 구성하려면 Policy 구성에 다음 파라미터를 추가하세요:

config:
  session_storage: redis
  redis:
    cluster_nodes:
    - ip: $CLUSTER_ADDRESS
      port: 6379
    port: 6379
    cloud_authentication:
      auth_provider: gcp
      gcp_service_account_json: $GCP_SERVICE_ACCOUNT

다음을 실제 값으로 바꾸세요:

  • $CLUSTER_ADDRESS: Memorystore 클러스터 주소예요.
  • $GCP_SERVICE_ACCOUNT: GCP 서비스 계정 JSON이에요.

여러 클라이언트

config.client_id와 config.client_secret은 OpenID Connect AI Auth Strategy 스키마의 배열 필드로, 플러그인에서와 동일한 방식으로 동작해요.

OIDC 인증 전략(config.client_id)과 클라이언트 시크릿(config.client_secret)을 구성할 수 있어요. 이때 ID와 클라이언트 쌍은 배열 내 위치를 기준으로 서로 대응돼요.

예를 들면 다음과 같아요:

config:
  issuer: example-issuer-url
  client_id:
    - my-first-client
    - my-second-client
  client_secret:
    - first-client-secret
    - second-client-secret

요청을 보낼 때 클라이언트 ID 인자를 포함하면 어떤 클라이언트를 대상으로 사용할지 지정할 수 있어요. 예를 들어, 인증 전략의 클라이언트 시크릿을 구성한 후에는 이름으로 클라이언트를 지정할 수 있어요:

curl -X GET "http://localhost:8000?client_id=my-second-client"

또는 인덱스 값(1부터 시작)으로 지정할 수도 있어요:

curl -X GET "http://localhost:8000?client_id=2"

AI Gateway는 우선순위에 따라 다음 위치에서 클라이언트 ID를 찾아요:

  1. config.client_arg가 설정되어 있으면, AI Gateway가 요청 헤더, URI 인자, 본문 순서로 해당 값을 확인해요.
  2. config.client_arg가 설정되어 있지 않으면, AI Gateway가 요청 헤더, URI 인자, 본문 순서로 client_id를 확인해요.
  3. 두 위치 모두에서 클라이언트를 찾지 못하면, AI Gateway가 첫 번째 클라이언트 ID와 클라이언트 시크릿 쌍을 사용해요.

참고: 인증 전략이 항상 클라이언트에서 직접 전달된 클라이언트 ID를 사용하기 때문에, client credentials 그랜트로는 여러 클라이언트를 구성할 수 없어요.

kongctl

ai_gateway_auth_strategies:
  - ref: multi-client-auth
    ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
    display_name: Multi-Client Auth
    name: multi-client-auth
    type: openid-connect
    config:
      issuer: https://dev-123456.okta.com
      client_id:
      - first-client-id
      - second-client-id
      client_secret:
      - source: CLIENT_SECRET_A
      - source: CLIENT_SECRET_B
      auth_methods:
      - client_credentials
      cache_tokens_salt: multi-client-auth-cache-salt

{: data-file="auth-strategy.yaml" data-tool="kongctl" }

다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:

  • AI_GATEWAY_ID: AI Gateway의 id예요.

UI

다음은 새 AI Auth Strategy를 만드는 절차예요. 권장 값은 백틱으로 표시돼요:

  1. Konnect에서 사이드바의 AI Gateway로 이동하세요.
  2. AI Gateway를 하나 선택하세요.
  3. Auth Strategies로 이동하세요.
  4. New auth strategy를 클릭하세요.
  5. Display name(예: Multi-Client Auth)을 입력하고 Type에서 Key authentication 또는 OpenID Connect 중 하나를 선택하세요.
  6. Key authentication을 선택했다면, 키 이름과 키를 확인할 위치(헤더, 쿼리, 본문)를 구성하세요.
  7. OpenID Connect를 선택했다면, Issuer, Client ID, Client secret을 입력하고 요청을 컨슈머와 매칭할 때 사용하는 클레임을 구성하세요.
  8. Create를 클릭하세요.

다음은 새 AI Policy를 만드는 절차예요. 권장 값은 백틱으로 표시돼요:

  1. Konnect에서 사이드바의 AI Gateway로 이동하세요.
  2. AI Gateway를 하나 선택하세요.
  3. Policies로 이동하세요.
  4. New Policy를 클릭하세요.
  5. Display Name(예: Multi-Client Auth)과 Name(예: multi-client-auth)을 입력하세요.
  6. 정책 Type을 선택하세요(예: openid-connect).
  7. 정책의 config 필드를 구성하세요.
  8. Create를 클릭하세요.

스키마

{
  "description": "Configuration for an auth strategy.",
  "type": "object",
  "properties": {
    "display_name": {
      "description": "The display name for this auth strategy instance.",
      "type": "string",
      "example": "Okta AI SE",
      "maxLength": 256,
      "minLength": 1
    },
    "name": {
      "description": "A user-defined unique identifier for this auth strategy instance, used as a stable human-readable reference. This value is immutable after creation.",
      "example": "okta-ai-se",
      "allOf": [
        {
          "$ref": "#/components/schemas/AIGatewayEntityIdentifier"
        }
      ]
    },
    "labels": {
      "$ref": "#/components/schemas/PublicLabels"
    },
    "managed_by": {
      "$ref": "#/components/schemas/ManagedBy"
    },
    "type": {
      "type": "string",
      "enum": [
        "openid-connect"
      ],
      "x-terraform-transform-const": true
    },
    "config": {
      "description": "Configuration for the OpenID Connect auth strategy.\nFor advanced use cases, additional config properties can be sent in the request body.\nSee: https://developer.konghq.com/plugins/openid-connect/reference/ for the list of properties\n",
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "auth_methods": {
          "description": "Types of credentials/grants to enable.",
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "authorization_code",
              "bearer",
              "client_credentials",
              "introspection",
              "kong_oauth2",
              "password",
              "refresh_token",
              "session",
              "userinfo"
            ]
          },
          "default": [
            "bearer",
            "client_credentials"
          ]
        },
        "client_id": {
          "description": "An array of strings representing the client id for the OpenID Connect provider.\nWhen multiple values are provided, the client ID and secrets pairs correspond based on their locations in the array.\n",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "client_secret": {
          "description": "An array of strings representing the client secret for the OpenID Connect provider.\nWhen multiple values are provided, the client ID and secrets pairs correspond based on their locations in the array.\n",
          "type": "array",
          "items": {
            "type": "string"
          },
          "writeOnly": true
        },
        "client_alg": {
          "description": "Algorithm to use for `client_secret_jwt` or `private_key_jwt` authentication.",
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "HS256",
              "HS384",
              "HS512",
              "RS256",
              "RS384",
              "RS512",
              "ES256",
              "ES384",
              "ES512",
              "PS256",
              "PS384",
              "PS512",
              "EdDSA"
            ]
          }
        },
        "client_auth": {
          "description": "Client authentication methods used with the identity provider.",
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "client_secret_basic",
              "client_secret_post",
              "client_secret_jwt",
              "private_key_jwt",
              "tls_client_auth",
              "self_signed_tls_client_auth",
              "none"
            ]
          }
        },
        "consumer_claims": {
          "description": "An array containing an array of string paths representing the location of the claim in a nested object.\nFor example, to map to user.info.id, set [ \"user\", \"info\", \"id\" ].\n",
          "type": "array",
          "items": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "consumer_groups_claim": {
          "description": "The claim used for consumer groups mapping.\nIf multiple values are set, it means the claim is inside a nested object of the token payload.\n",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "consumer_groups_optional": {
          "description": "Do not terminate the request if consumer groups mapping fails.\n",
          "type": "boolean",
          "default": false
        },
        "consumer_by": {
          "description": "Consumer fields used when mapping a token claim to a Kong consumer.",
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "id",
              "username",
              "custom_id"
            ]
          },
          "default": [
            "username",
            "custom_id"
          ]
        },
        "consumer_optional": {
          "description": "Do not terminate the request if consumer mapping fails.\n",
          "type": "boolean",
          "default": false
        },
        "credential_claim": {
          "description": "Claim path used to derive virtual credentials when consumer mapping is not used.",
          "type": "array",
          "items": {
            "type": "string"
          },
          "default": [
            "sub"
          ]
        },
        "issuer": {
          "description": "URL that identifies the OpenID Provider",
          "type": "string",
          "example": "https://dev-123456.okta.com"
        },
        "introspection_endpoint": {
          "description": "Overrides the introspection endpoint returned by discovery.",
          "type": "string",
          "format": "uri",
          "x-referenceable": true
        },
        "mtls_introspection_endpoint": {
          "description": "mTLS alias for the introspection endpoint.",
          "type": "string",
          "format": "uri"
        },
        "cache_introspection": {
          "description": "Cache introspection endpoint requests.",
          "type": "boolean",
          "default": true
        },
        "jwks_endpoint": {
          "description": "Overrides the JWKS endpoint returned by discovery.",
          "type": "string",
          "format": "uri"
        },
        "leeway": {
          "description": "Leeway, in seconds, for validating token time claims.",
          "type": "integer",
          "default": 0,
          "minimum": 0
        },
        "scopes": {
          "description": "This field is referenceable.\n",
          "type": "array",
          "items": {
            "type": "string"
          },
          "default": [
            "openid"
          ]
        },
        "audience_required": {
          "description": "Audiences required in the access token or introspection response.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "ssl_verify": {
          "type": "boolean",
          "default": true
        },
        "hide_credentials": {
          "description": "Remove credentials used for authentication before proxying the request upstream.",
          "type": "boolean",
          "default": true
        },
        "keepalive": {
          "description": "Reuse HTTP client connections for identity provider requests.",
          "type": "boolean",
          "default": true
        },
        "timeout": {
          "description": "Network I/O timeout, in milliseconds, for identity provider requests.",
          "type": "integer",
          "default": 10000,
          "minimum": 0
        },
        "http_version": {
          "description": "HTTP version used for identity provider requests.",
          "type": "number",
          "default": 1.1,
          "enum": [
            1,
            1.1
          ]
        },
        "http_proxy": {
          "description": "HTTP proxy used for identity provider requests.",
          "type": "string",
          "format": "uri"
        },
        "http_proxy_authorization": {
          "description": "Authorization header value sent to the HTTP proxy.",
          "type": "string",
          "writeOnly": true
        },
        "https_proxy": {
          "description": "HTTPS proxy used for identity provider requests.",
          "type": "string",
          "format": "uri"
        },
        "https_proxy_authorization": {
          "description": "Authorization header value sent to the HTTPS proxy.",
          "type": "string",
          "writeOnly": true
        },
        "no_proxy": {
          "description": "Comma-separated hosts that bypass the configured proxies.",
          "type": "string"
        },
        "upstream_headers": {
          "description": "Map token claims to upstream headers using path-based access.",
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "header",
              "path"
            ],
            "properties": {
              "header": {
                "description": "The name of the header.",
                "type": "string"
              },
              "path": {
                "description": "The path of the header value.",
                "type": "array",
                "items": {
                  "type": "string"
                },
                "minItems": 1
              }
            }
          }
        },
        "cache_tokens_salt": {
          "description": "Salt used for generating the cache key that is used for caching the token endpoint requests.\n",
          "type": "string"
        },
        "principals": {
          "description": "Map a request to a Kong Identity principal after token verification.",
          "type": "object",
          "properties": {
            "enabled": {
              "description": "When true, look up a Kong Identity principal after token verification.",
              "type": "boolean",
              "default": false
            },
            "directory": {
              "description": "The Kong Identity directory instance to look up against.",
              "type": "string",
              "default": "default",
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "principal_by": {
              "description": "Custom identity name for a custom Kong Identity lookup. When absent and principal_claim is set,\na lookup is performed using principal_claim as the claim name instead of the default sub claim.\n",
              "type": "string",
              "minLength": 1
            },
            "principal_claim": {
              "description": "Token claim used for the Kong Identity lookup. If multiple values are set, the claim is inside a\nnested object of the token payload. Used together with, or instead of, principal_by.\n",
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "minItems": 1
            },
            "match_consumer": {
              "description": "If a consumer is attached to the matched principal, load it and set it in the request context,\noverriding consumer_by.\n",
              "type": "boolean",
              "default": true
            },
            "match_consumer_groups": {
              "description": "If consumer groups are attached to the matched principal, load them, overriding consumer_groups_claim.\n",
              "type": "boolean",
              "default": true
            },
            "error_on_miss": {
              "description": "When true (default), reject the request if no principal is matched in Kong Identity after token\nverification. When false, the request continues without an authenticated principal set.\n",
              "type": "boolean",
              "default": true
            }
          }
        }
      },
      "required": [
        "cache_tokens_salt"
      ]
    }
  },
  "required": [
    "display_name",
    "name",
    "type"
  ],
  "title": "AIGatewayAuthStrategyOpenIDConnectConfig"
}

관련 리소스

더 알아보기 (Learn more)

  • AI Auth Strategy 엔티티의 구성 방법과 identity 매핑, key auth와의 차이를 자세히 설명해요 — AI Auth Strategies
  • 이 인증 전략의 config가 전달되는 Kong Gateway OpenID Connect 플러그인의 전체 기능을 확인할 수 있어요 — OpenID Connect plugin
  • 직접 IdP를 운영하지 않아도 바로 연동할 수 있는 Kong의 관리형 IdP예요 — Kong Identity
  • 인증된 토큰이 매핑되는 AI Consumer 엔티티의 개념을 이해하는 데 도움이 돼요 — AI Consumers
  • Kong Identity로 AI Model 트래픽의 AI Consumer를 식별하는 실전 가이드예요 — Identify AI Consumers on AI Model traffic with Kong Identity