このページは、まだ日本語ではご利用いただけません。翻訳中です。
基本構成例
以下の例では、openid-connectプラグインをで有効にするための一般的な設定をご紹介します。
次のリクエストを行います。
curl -X POST http://localhost:8001/services/{serviceName|Id}/plugins \
    --header "accept: application/json" \
    --header "Content-Type: application/json" \
    --data '
    {
  "name": "openid-connect",
  "config": {
    "auth_methods": [
      "authorization_code",
      "session"
    ],
    "issuer": "http://example.org",
    "client_id": [
      "<client-id>"
    ],
    "client_secret": [
      "<client-secret>"
    ],
    "session_secret": "<session-secret>",
    "response_mode": "form_post"
  }
}
    '
| SERVICE_NAME | IDを、このプラグイン構成の対象となるサービスの idまたはnameに置き換えてください。 | 
独自のアクセストークン、リージョン、コントロールプレーンID、サービスIDを代入して、次のリクエストを行ってください。
curl -X POST \
https://{us|eu}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/services/{serviceId}/plugins \
    --header "accept: application/json" \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer TOKEN" \
    --data '{"name":"openid-connect","config":{"auth_methods":["authorization_code","session"],"issuer":"http://example.org","client_id":["<client-id>"],"client_secret":["<client-secret>"],"session_secret":"<session-secret>","response_mode":"form_post"}}'
地域固有のURLと個人アクセストークンの詳細については、 Konnect API referenceをご参照ください。
まず、KongPlugin リソースを作成します:
echo "
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: openid-connect-example
plugin: openid-connect
config:
  auth_methods:
  - authorization_code
  - session
  issuer: http://example.org
  client_id:
  - "<client-id>"
  client_secret:
  - "<client-secret>"
  session_secret: "<session-secret>"
  response_mode: form_post
" | kubectl apply -f -
次に、次のようにserviceに注釈を付けて、KongPluginリソースをイングレスに適用します。
kubectl annotate service SERVICE_NAME konghq.com/plugins=openid-connect-example
SERVICE_NAMEを、このプラグイン構成が対象とするサービスの名前に置き換えます。 kubectl get serviceを実行すると、利用可能なイングレスを確認できます。
注: KongPluginリソースは一度だけ定義するだけで、ネームスペース内の任意のサービス、コンシューマー、またはルートに適用できます。プラグインをクラスター全体で利用可能にしたい場合は、KongPluginの代わりにKongClusterPluginとしてリソースを作成してください。
このセクションを宣言型構成ファイルに追加します。
plugins:
- name: openid-connect
  service: SERVICE_NAME|ID
  config:
    auth_methods:
    - authorization_code
    - session
    issuer: http://example.org
    client_id:
    - "<client-id>"
    client_secret:
    - "<client-secret>"
    session_secret: "<session-secret>"
    response_mode: form_post
| SERVICE_NAME | IDを、このプラグイン構成の対象となるサービスの idまたはnameに置き換えてください。 | 
前提条件: パーソナルアクセストークンの設定
terraform {
  required_providers {
    konnect = {
      source  = "kong/konnect"
    }
  }
}
provider "konnect" {
  personal_access_token = "kpat_YOUR_TOKEN"
  server_url            = "https://us.api.konghq.com/"
}
Kong Konnectゲートウェイプラグインを作成するには、Terraform 構成に以下を追加します。
resource "konnect_gateway_plugin_openid_connect" "my_openid_connect" {
  enabled = true
  config = {
    auth_methods = ["authorization_code", "session"]
    issuer = "http://example.org"
    client_id = ["<client-id>"]
    client_secret = ["<client-secret>"]
    session_secret = "<session-secret>"
    response_mode = "form_post"
  }
  control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
  service = {
    id = konnect_gateway_service.my_service.id
  }
}
以下の例では、openid-connectプラグインをで有効にするための一般的な設定をご紹介します。
次のリクエストを行います。
curl -X POST http://localhost:8001/routes/{routeName|Id}/plugins \
    --header "accept: application/json" \
    --header "Content-Type: application/json" \
    --data '
    {
  "name": "openid-connect",
  "config": {
    "auth_methods": [
      "authorization_code",
      "session"
    ],
    "issuer": "http://example.org",
    "client_id": [
      "<client-id>"
    ],
    "client_secret": [
      "<client-secret>"
    ],
    "session_secret": "<session-secret>",
    "response_mode": "form_post"
  }
}
    '
| ROUTE_NAME | IDを、このプラグイン構成が対象とするルートのid またはnameに置き換えてください。 | 
独自のアクセストークン、リージョン、コントロールプレーン(CP)ID、ルートIDを代入して、次のリクエストをしてください。
curl -X POST \
https://{us|eu}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/routes/{routeId}/plugins \
    --header "accept: application/json" \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer TOKEN" \
    --data '{"name":"openid-connect","config":{"auth_methods":["authorization_code","session"],"issuer":"http://example.org","client_id":["<client-id>"],"client_secret":["<client-secret>"],"session_secret":"<session-secret>","response_mode":"form_post"}}'
地域固有のURLと個人アクセストークンの詳細については、 Konnect API referenceをご参照ください。
まず、KongPlugin リソースを作成します:
echo "
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: openid-connect-example
plugin: openid-connect
config:
  auth_methods:
  - authorization_code
  - session
  issuer: http://example.org
  client_id:
  - "<client-id>"
  client_secret:
  - "<client-secret>"
  session_secret: "<session-secret>"
  response_mode: form_post
" | kubectl apply -f -
次に、次のようにingressに注釈を付けて、KongPluginリソースをイングレスに適用します。
kubectl annotate ingress INGRESS_NAME konghq.com/plugins=openid-connect-example
INGRESS_NAMEを、このプラグイン構成がターゲットとするイングレス名に置き換えます。 kubectl get ingressを実行すると、利用可能なイングレスを確認できます。
注: KongPluginリソースは一度だけ定義するだけで、ネームスペース内の任意のサービス、コンシューマー、またはルートに適用できます。プラグインをクラスター全体で利用可能にしたい場合は、KongPluginの代わりにKongClusterPluginとしてリソースを作成してください。
このセクションを宣言型構成ファイルに追加します。
plugins:
- name: openid-connect
  route: ROUTE_NAME|ID
  config:
    auth_methods:
    - authorization_code
    - session
    issuer: http://example.org
    client_id:
    - "<client-id>"
    client_secret:
    - "<client-secret>"
    session_secret: "<session-secret>"
    response_mode: form_post
| ROUTE_NAME | IDを、このプラグイン構成が対象とするルートのid またはnameに置き換えてください。 | 
前提条件: パーソナルアクセストークンの設定
terraform {
  required_providers {
    konnect = {
      source  = "kong/konnect"
    }
  }
}
provider "konnect" {
  personal_access_token = "kpat_YOUR_TOKEN"
  server_url            = "https://us.api.konghq.com/"
}
Kong Konnectゲートウェイプラグインを作成するには、Terraform 構成に以下を追加します。
resource "konnect_gateway_plugin_openid_connect" "my_openid_connect" {
  enabled = true
  config = {
    auth_methods = ["authorization_code", "session"]
    issuer = "http://example.org"
    client_id = ["<client-id>"]
    client_secret = ["<client-secret>"]
    session_secret = "<session-secret>"
    response_mode = "form_post"
  }
  control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
  route = {
    id = konnect_gateway_route.my_route.id
  }
}
どのサービス、ルート、コンシューマー、コンシューマーグループにも関連しないプラグインは_global_とみなされ、 すべてのリクエストで実行されます。
- 自己管理型のKong Gateway Enterpriseでは、プラグインは特定のワークスペース内のすべてのエンティティに適用されます。
 - セルフマネージドKong Gateway (OSS)では、プラグインは環境全体に適用されます。
 - Konnectでは、プラグインは特定のコントロールプレーン(CP)内のすべてのエンティティに適用されます。
 
詳しくはとプラグインの優先順位の セクションをご覧ください。
以下の例では、OpenID Connectプラグインをグローバルに有効にするための典型的な設定をいくつかご紹介します。
次のリクエストを行います。
curl -X POST http://localhost:8001/plugins/ \
    --header "accept: application/json" \
    --header "Content-Type: application/json" \
    --data '
    {
  "name": "openid-connect",
  "config": {
    "auth_methods": [
      "authorization_code",
      "session"
    ],
    "issuer": "http://example.org",
    "client_id": [
      "<client-id>"
    ],
    "client_secret": [
      "<client-secret>"
    ],
    "session_secret": "<session-secret>",
    "response_mode": "form_post"
  }
}
    '
独自のアクセストークン、リージョン、コントロールプレーン(CP)IDを代入して、次のリクエストをしてください。
curl -X POST \
https://{us|eu}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/plugins/ \
    --header "accept: application/json" \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer TOKEN" \
    --data '{"name":"openid-connect","config":{"auth_methods":["authorization_code","session"],"issuer":"http://example.org","client_id":["<client-id>"],"client_secret":["<client-secret>"],"session_secret":"<session-secret>","response_mode":"form_post"}}'
地域固有のURLと個人アクセストークンの詳細については、 Konnect API referenceをご参照ください。
KongClusterPlugin作成する リソースを作成し、グローバルとしてラベル付けします。
apiVersion: configuration.konghq.com/v1
kind: KongClusterPlugin
metadata:
  name: <global-openid-connect>
  annotations:
    kubernetes.io/ingress.class: kong
  labels:
    global: "true"
config:
  auth_methods:
  - authorization_code
  - session
  issuer: http://example.org
  client_id:
  - "<client-id>"
  client_secret:
  - "<client-secret>"
  session_secret: "<session-secret>"
  response_mode: form_post
plugin: openid-connect
宣言型構成ファイルにpluginsエントリを追加します。
plugins:
- name: openid-connect
  config:
    auth_methods:
    - authorization_code
    - session
    issuer: http://example.org
    client_id:
    - "<client-id>"
    client_secret:
    - "<client-secret>"
    session_secret: "<session-secret>"
    response_mode: form_post
前提条件: パーソナルアクセストークンの設定
terraform {
  required_providers {
    konnect = {
      source  = "kong/konnect"
    }
  }
}
provider "konnect" {
  personal_access_token = "kpat_YOUR_TOKEN"
  server_url            = "https://us.api.konghq.com/"
}
Kong Konnectゲートウェイプラグインを作成するには、Terraform 構成に以下を追加します。
resource "konnect_gateway_plugin_openid_connect" "my_openid_connect" {
  enabled = true
  config = {
    auth_methods = ["authorization_code", "session"]
    issuer = "http://example.org"
    client_id = ["<client-id>"]
    client_secret = ["<client-secret>"]
    session_secret = "<session-secret>"
    response_mode = "form_post"
  }
  control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
}