コンテンツにスキップ
Kong Logo | Kong Docs Logo
  • ドキュメント
    • API仕様を確認する
      View all API Specs すべてのAPI仕様を表示 View all API Specs arrow image
    • ドキュメンテーション
      API Specs
      Kong Gateway
      軽量、高速、柔軟なクラウドネイティブAPIゲートウェイ
      Kong Konnect
      SaaSのエンドツーエンド接続のための単一プラットフォーム
      Kong AI Gateway
      GenAI インフラストラクチャ向けマルチ LLM AI Gateway
      Kong Mesh
      Kuma と Envoy をベースにしたエンタープライズサービスメッシュ
      decK
      Kongの構成を宣言型で管理する上で役立ちます
      Kong Ingress Controller
      Kubernetesクラスタ内で動作し、Kongをプロキシトラフィックに設定する
      Kong Gateway Operator
      YAMLマニフェストを使用してKubernetes上のKongデプロイメントを管理する
      Insomnia
      コラボレーティブAPI開発プラットフォーム
  • Plugin Hub
    • Plugin Hubを探索する
      View all plugins すべてのプラグインを表示 View all plugins arrow image
    • 機能性 すべて表示 View all arrow image
      すべてのプラグインを表示
      AI's icon
      AI
      マルチ LLM AI Gatewayプラグインを使用してAIトラフィックを管理、保護、制御する
      認証's icon
      認証
      認証レイヤーでサービスを保護する
      セキュリティ's icon
      セキュリティ
      追加のセキュリティレイヤーでサービスを保護する
      トラフィック制御's icon
      トラフィック制御
      インバウンドおよびアウトバウンドAPIトラフィックの管理、スロットル、制限
      サーバーレス's icon
      サーバーレス
      他のプラグインと組み合わせてサーバーレス関数を呼び出します
      分析と監視's icon
      分析と監視
      APIとマイクロサービストラフィックを視覚化、検査、監視
      変革's icon
      変革
      Kongでリクエストとレスポンスをその場で変換
      ログ記録's icon
      ログ記録
      インフラストラクチャに最適なトランスポートを使用して、リクエストと応答データをログに記録します
  • サポート
  • コミュニティ
  • Kongアカデミー
デモを見る 無料トライアルを開始
Kong Gateway
2.8.x LTS
  • Home icon
  • Kong Gateway
  • Configure
  • Authentication Reference
report-issue問題を報告する
  • Kong Gateway
  • Kong Konnect
  • Kong Mesh
  • Kong AI Gateway
  • Plugin Hub
  • decK
  • Kong Ingress Controller
  • Kong Gateway Operator
  • Insomnia
  • Kuma

  • ドキュメント投稿ガイドライン
  • 3.10.x (latest)
  • 3.9.x
  • 3.8.x
  • 3.7.x
  • 3.6.x
  • 3.5.x
  • 3.4.x (LTS)
  • 3.3.x
  • 2.8.x (LTS)
  • アーカイブ (2.6より前)
  • Introduction
    • Overview of Kong Gateway
    • Version Support Policy
    • Stages of Software Availability
    • Changelog
  • Install and Run
    • Overview
    • Kubernetes
    • Helm
    • OpenShift with Helm
    • Docker
    • Amazon Linux
    • CentOS
    • Debian
    • RHEL
    • Ubuntu
    • Migrating from OSS to EE
    • Upgrade Kong Gateway
    • Upgrade Kong Gateway OSS
    • Upgrade from 2.8 LTS to 3.4 LTS
  • Get Started
    • Quickstart Guide
      • Configuring a Service
      • Configuring a gRPC Service
      • Enabling Plugins
      • Adding Consumers
    • Comprehensive Guide
      • Prepare to Administer
      • Expose your Services
      • Protect your Services
      • Improve Performance
      • Secure Services
      • Set Up Intelligent Load Balancing
      • Manage Administrative Teams
      • Publish, Locate, and Consume Services
  • Plan and Deploy
    • Running Kong as a Non-Root User
    • Resource Sizing Guidelines
    • Hybrid Mode
      • Deploy Kong Gateway in Hybrid Mode
    • Kubernetes Deployment Options
    • Control Kong Gateway through systemd
    • Performance Testing Framework
    • DNS Considerations
    • Default Ports
    • Licenses
      • Access Your License
      • Deploy Your License
      • Monitor License Usage
    • Security
      • Start Kong Gateway Securely
      • Keyring and Data Encryption
      • Kong Security Update Process
      • Secrets Management
        • Getting Started
        • Advanced Usage
        • Backends
          • Environment Variables
          • AWS Secrets Manager
          • GCP Secret Manager
          • HashiCorp Vault
        • Reference Format
  • Configure
    • Authentication and Authorization
      • Authentication Reference
      • OpenID Connect Plugin
        • OpenID Connect with Curity
        • OpenID Connect with Azure AD
        • OpenID Connect with Google
        • OpenID Connect with Okta
        • OpenID Connect with Auth0
        • OpenID Connect with Cognito
        • OpenID Connect Plugin Reference
      • Allowing Multiple Authentication Methods
      • Auth for Kong Manager
        • Create a Super Admin
        • Configure Networking
        • Configure Kong Manager to Send Email
        • Reset Passwords and RBAC Tokens
        • Configure Workspaces
        • Basic Auth
        • LDAP
        • OIDC
        • Sessions
      • Role-based Access Control (RBAC)
        • Add a Role
        • Add a User
        • Add an Admin
      • Mapping LDAP Service Directory Groups to Kong Roles
    • Configure gRPC Plugins
    • GraphQL Quickstart
    • Logging Reference
    • Network and Firewall
  • Dev Portal
    • Overview
    • Enable the Dev Portal
    • Structure and File Types
    • Portal API Documentation
    • Working with Templates
    • Using the Editor
    • Configuration
      • Authentication
        • Basic Auth
        • Key Auth
        • OIDC
        • Sessions
        • Adding Custom Registration Fields
      • SMTP
      • Workspaces
    • Administration
      • Manage Developers
      • Developer Roles and Content Permissions
      • Application Registration
        • Authorization Provider Strategy
        • Enable Application Registration
        • Enable Key Authentication for Application Registration
        • External OAuth2 Support
        • Set up Okta and Kong for external OAuth
        • Set Up Azure AD and Kong for External Authentication
        • Manage Applications
    • Customization
      • Easy Theme Editing
      • Migrating Templates Between Workspaces
      • Markdown Rendering Module
      • Customizing Portal Emails
      • Adding and Using JavaScript Assets
      • Single Page App in Dev Portal
      • Alternate OpenAPI Renderer
    • Helpers CLI
  • Monitor
    • Kong Vitals
      • Metrics
      • Reports
      • Vitals with InfluxDB
      • Vitals with Prometheus
      • Estimate Vitals Storage in PostgreSQL
    • Prometheus plugin
    • Zipkin plugin
  • Reference
    • Admin API
      • DB-less Mode
      • Declarative Configuration
      • Supported Content Types
      • Information Routes
      • Health Routes
      • Tags
      • Service Object
      • Route Object
      • Consumer Object
      • Plugin Object
      • Certificate Object
      • CA Certificate Object
      • SNI Object
      • Upstream Object
      • Target Object
      • Vaults Beta
      • Licenses
        • Licenses Reference
        • Licenses Examples
      • Workspaces
        • Workspaces Reference
        • Workspace Examples
      • RBAC
        • RBAC Reference
        • RBAC Examples
      • Admins
        • API Reference
        • Examples
      • Developers
      • Consumer Groups
        • API Reference
        • Examples
      • Event Hooks
        • Event Hooks Reference
        • Examples
      • Audit Logging
      • Keyring and Data Encryption
      • Securing the Admin API
    • DB-less and Declarative Configuration
    • Configuration Reference
    • CLI Reference
    • Load Balancing Reference
    • Proxy Reference
    • Rate Limiting Library
    • Health Checks and Circuit Breakers Reference
    • Clustering Reference
    • Plugin Development Kit
      • kong.client
      • kong.client.tls
      • kong.cluster
      • kong.ctx
      • kong.ip
      • kong.log
      • kong.nginx
      • kong.node
      • kong.request
      • kong.response
      • kong.router
      • kong.service
      • kong.service.request
      • kong.service.response
      • kong.table
      • kong.vault
    • Plugin Development Guide
      • Introduction
      • File structure
      • Implementing custom logic
      • Plugin configuration
      • Accessing the datastore
      • Storing custom entities
      • Caching custom entities
      • Extending the Admin API
      • Writing tests
      • (un)Installing your plugin
    • Plugins in Other Languages
    • File Permissions Reference
enterprise-switcher-icon 次に切り替える: OSS
On this pageOn this page
  • Generic authentication
  • Consumers
  • Anonymous Access
  • Multiple Authentication

このページは、まだ日本語ではご利用いただけません。翻訳中です。

旧バージョンのドキュメントを参照しています。 最新のドキュメントはこちらをご参照ください。

Authentication Reference

Traffic to your Upstream services (APIs or microservices) is typically controlled by the application and configuration of various Kong authentication plugins. Because Kong’s Service entity represents a 1-to-1 mapping of your own upstream services, the simplest scenario is to configure authentication plugins on the Services of your choosing.

Generic authentication

The most common scenario is to require authentication and to not allow access for any unauthenticated request. To achieve this, any of the authentication plugins can be used. The generic scheme/flow of those plugins works as follows:

  1. Apply an auth plugin to a Service, or globally (you cannot apply one on consumers)
  2. Create a consumer entity
  3. Provide the consumer with authentication credentials for the specific authentication method
  4. Now whenever a request comes in, Kong will check the provided credentials (depends on the auth type) and it will either block the request if it cannot validate, or add consumer and credential details in the headers and forward the request.

The generic flow above does not always apply, for example when using external authentication like LDAP, then there is no consumer to be identified, and only the credentials will be added in the forwarded headers.

The authentication method specific elements and examples can be found in each plugin’s documentation.

Consumers

The easiest way to think about consumers is to map them one-on-one to users. Yet, to Kong this does not matter. The core principle for consumers is that you can attach plugins to them, and hence customize request behavior. So you might have mobile apps, and define one consumer for each app, or version of it. Or have a consumer per platform, e.g. an android consumer, an iOS consumer, etc.

It is an opaque concept to Kong and hence they are called “consumers” and not “users”.

Anonymous Access

Kong has the ability to configure a given Service to allow both authenticated and anonymous access. You might use this configuration to grant access to anonymous users with a low rate limit, and grant access to authenticated users with a higher rate limit.

To configure a Service like this, you first apply your selected authentication plugin, then create a new consumer to represent anonymous users, then configure your authentication plugin to allow anonymous access. Here is an example, which assumes you have already configured a Service named example-service and the corresponding Route:

  1. Create an example Service and a Route

    Issue the following cURL request to create example-service pointing to httpbin.konghq.com, which will echo the request:

     $ curl -i -X POST \
       --url http://localhost:8001/services/ \
       --data 'name=example-service' \
       --data 'url=https://httpbin.konghq.com/anything'
    

    Add a Route to the Service:

     $ curl -i -X POST \
       --url http://localhost:8001/services/example-service/routes \
       --data 'paths[]=/auth-sample'
    

    The url http://localhost:8000/auth-sample will now echo whatever is being requested.

  2. Configure the key-auth Plugin for your Service

    Issue the following cURL request to add a plugin to a Service:

     $ curl -i -X POST \
       --url http://localhost:8001/services/example-service/plugins/ \
       --data 'name=key-auth'
    

    Be sure to note the created Plugin id - you’ll need it in step 5.

  3. Verify that the key-auth plugin is properly configured

    Issue the following cURL request to verify that the key-auth plugin was properly configured on the Service:

     $ curl -i -X GET \
       --url http://localhost:8000/auth-sample
    

    Since you did not specify the required apikey header or parameter, and you have not yet enabled anonymous access, the response should be 403 Forbidden:

     HTTP/1.1 403 Forbidden
     ...
    
     {
       "message": "No API key found in headers or querystring"
     }
    
  4. Create an anonymous Consumer

    Every request proxied by Kong must be associated with a Consumer. You’ll now create a Consumer named anonymous_users (that Kong will use when proxying anonymous access) by issuing the following request:

     $ curl -i -X POST \
       --url http://localhost:8001/consumers/ \
       --data "username=anonymous_users"
    

    You should see a response similar to the one below:

     HTTP/1.1 201 Created
     Content-Type: application/json
     Connection: keep-alive
    
     {
       "username": "anonymous_users",
       "created_at": 1428555626000,
       "id": "bbdf1c48-19dc-4ab7-cae0-ff4f59d87dc9"
     }
    

    Be sure to note the Consumer id - you’ll need it in the next step.

  5. Enable anonymous access

    You’ll now re-configure the key-auth plugin to permit anonymous access by issuing the following request (replace the sample uuids below by the id values from step 2 and 4):

     $ curl -i -X PATCH \
       --url http://localhost:8001/plugins/<your-plugin-id> \
       --data "config.anonymous=<your-consumer-id>"
    

    The config.anonymous=<your-consumer-id> parameter instructs the key-auth plugin on this Service to permit anonymous access, and to associate such access with the Consumer id we received in the previous step. It is required that you provide a valid and pre-existing Consumer id in this step - validity of the Consumer id is not currently checked when configuring anonymous access, and provisioning of a Consumer id that doesn’t already exist will result in an incorrect configuration.

  6. Check anonymous access

    Confirm that your Service now permits anonymous access by issuing the following request:

     $ curl -i -X GET \
       --url http://localhost:8000/auth-sample
    

    This is the same request you made in step #3; however, this time the request should succeed because you enabled anonymous access in step #5.

    The response (which is the request as httpbin received it) should have these elements:

     {
       ...
       "headers": {
         ...
         "x-consumer-id": "713c592c-38b8-4f5b-976f-1bd2b8069494",
         "x-consumer-username": "anonymous_users",
         "x-anonymous-consumer": "true",
         ...
       },
       ...
     }
    

    It shows the request was successful, but anonymous.

Multiple Authentication

Kong supports multiple authentication plugins for a given Service, allowing different clients to use different authentication methods to access a given Service or Route.

The behaviour of the auth plugins can be set to do either a logical AND, or a logical OR when evaluating multiple authentication credentials. The key to the behaviour is the config.anonymous property.

  • config.anonymous not set
    If this property is not set (empty), then the auth plugins will always perform authentication and return a 40x response if not validated. This results in a logical AND when multiple auth plugins are being invoked.
  • config.anonymous set to a valid consumer id
    In this case, the auth plugin will only perform authentication if it was not already authenticated. When authentication fails, it will not return a 40x response, but set the anonymous consumer as the consumer. This results in a logical OR + ‘anonymous access’ when multiple auth plugins are being invoked.

NOTE 1: Either all or none of the auth plugins must be configured for anonymous access. The behaviour is undefined if they are mixed.

NOTE 2: When using the AND method, the last plugin executed will be the one setting the credentials passed to the upstream service. With the OR method, it will be the first plugin that successfully authenticates the consumer, or the last plugin that will set its configured anonymous consumer.

NOTE 3: When using the OAuth2 plugin in an AND fashion, then also the OAuth2 endpoints for requesting tokens and so forth will require authentication by the other configured auth plugins.

When multiple authentication plugins are enabled in an OR fashion on a given service, and you want anonymous access to be forbidden, then the Request Termination plugin should be configured on the anonymous consumer. Failure to do so will allow unauthorized requests.

Thank you for your feedback.
Was this page useful?
情報が多すぎる場合 close cta icon
Kong Konnectを使用すると、より多くの機能とより少ないインフラストラクチャを実現できます。月額1Mリクエストが無料。
無料でお試しください
  • Kong
    APIの世界を動かす

    APIマネジメント、サービスメッシュ、イングレスコントローラーの統合プラットフォームにより、開発者の生産性、セキュリティ、パフォーマンスを大幅に向上します。

    • 製品
      • Kong Konnect
      • Kong Gateway Enterprise
      • Kong Gateway
      • Kong Mesh
      • Kong Ingress Controller
      • Kong Insomnia
      • 製品アップデート
      • 始める
    • ドキュメンテーション
      • Kong Konnectドキュメント
      • Kong Gatewayドキュメント
      • Kong Meshドキュメント
      • Kong Insomniaドキュメント
      • Kong Konnect Plugin Hub
    • オープンソース
      • Kong Gateway
      • Kuma
      • Insomnia
      • Kongコミュニティ
    • 会社概要
      • Kongについて
      • お客様
      • キャリア
      • プレス
      • イベント
      • お問い合わせ
  • 利用規約• プライバシー• 信頼とコンプライアンス
© Kong Inc. 2025