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

Key Auth 플러그인 구성 레퍼런스

원문 보기 위키 갱신

Key Auth 플러그인 구성 레퍼런스 (Key Auth Plugin Configuration Reference)

이 문서는 Kong의 Key 인증 플러그인에서 설정할 수 있는 모든 구성 파라미터를 정리한 레퍼런스예요. API 키를 헤더, 쿼리 파라미터, 요청 본문 중 어디에서 읽을지 정하는 key_in_header, key_in_query, key_in_body 필드와 기본값을 하나씩 살펴볼 수 있어요. 인증 실패 시 동작을 바꾸는 anonymous, 업스트림 서비스에서 자격 증명을 숨길지 정하는 hide_credentials 같은 실무에서 자주 쓰는 옵션도 다뤄요. Konnect Identity Realms나 principals처럼 Kong Identity와 연동되는 고급 설정까지 함께 확인할 수 있어요

출처: 문서

본문

{
  "properties": {
    "config": {
      "properties": {
        "anonymous": {
          "description": "An optional string (consumer UUID or username) value to use as an “anonymous” consumer if authentication fails. If empty (default null), the request will fail with an authentication failure `4xx`.",
          "type": "string"
        },
        "hide_credentials": {
          "default": true,
          "description": "An optional boolean value telling the plugin to show or hide the credential from the upstream service. If `true`, the plugin strips the credential from the request.",
          "type": "boolean"
        },
        "identity_realms": {
          "description": "A configuration of Konnect Identity Realms that indicate where to source a consumer from. Defaults to a single local realm. Set this field to an empty array explicitly when the plugin enables Kong Identity `principals`, since the two are mutually exclusive.",
          "items": {
            "properties": {
              "id": {
                "description": "A string representing a UUID (universally unique identifier).",
                "type": "string"
              },
              "region": {
                "type": "string"
              },
              "scope": {
                "default": "cp",
                "enum": [
                  "cp",
                  "realm"
                ],
                "type": "string"
              }
            },
            "type": "object"
          },
          "type": "array"
        },
        "key_in_body": {
          "default": false,
          "description": "If enabled, the plugin reads the request body. Supported MIME types: `application/www-form-urlencoded`, `application/json`, and `multipart/form-data`.",
          "type": "boolean"
        },
        "key_in_header": {
          "default": true,
          "description": "If enabled (default), the plugin reads the request header and tries to find the key in it.",
          "type": "boolean"
        },
        "key_in_query": {
          "default": true,
          "description": "If enabled (default), the plugin reads the query parameter in the request and tries to find the key in it.",
          "type": "boolean"
        },
        "key_names": {
          "default": [
            "apikey"
          ],
          "description": "Describes an array of parameter names where the plugin will look for a key. The key names may only contain [a-z], [A-Z], [0-9], [_] underscore, and [-] hyphen.",
          "items": {
            "description": "A string representing an HTTP header name.",
            "type": "string"
          },
          "type": "array"
        },
        "principals": {
          "properties": {
            "directory": {
              "default": "default",
              "description": "The Kong Identity directory instance to authenticate against.",
              "type": "string"
            },
            "enabled": {
              "default": false,
              "description": "When true, authenticate against Kong Identity instead of local credentials.",
              "type": "boolean"
            },
            "error_on_miss": {
              "default": true,
              "description": "When true (default), return 401 if no matching principal is found in Kong Identity. When false, allow the request to continue unauthenticated instead.",
              "type": "boolean"
            }
          },
          "type": "object"
        },
        "realm": {
          "description": "When authentication fails the plugin sends `WWW-Authenticate` header with `realm` attribute value.",
          "type": "string"
        },
        "run_on_preflight": {
          "default": true,
          "description": "A boolean value that indicates whether the plugin should run (and try to authenticate) on `OPTIONS` preflight requests. If set to `false`, then `OPTIONS` requests are always allowed.",
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "expressions": {
      "additionalProperties": true,
      "type": "object"
    },
    "protocols": {
      "default": [
        "grpc",
        "grpcs",
        "http",
        "https",
        "ws",
        "wss"
      ],
      "description": "A list of the request protocols that will trigger this plugin. The default value, as well as the possible values allowed on this field, may change depending on the plugin type. For example, plugins that only work in stream mode will only support tcp and tls.",
      "items": {
        "enum": [
          "grpc",
          "grpcs",
          "http",
          "https",
          "ws",
          "wss"
        ],
        "type": "string"
      },
      "type": "array"
    },
    "route": {
      "additionalProperties": false,
      "description": "If set, the plugin will only activate when receiving requests via the specified route. Leave unset for the plugin to activate regardless of the route being used.",
      "properties": {
        "id": {
          "type": "string"
        }
      },
      "type": "object"
    },
    "service": {
      "additionalProperties": false,
      "description": "If set, the plugin will only activate when receiving requests via one of the routes belonging to the specified Service. Leave unset for the plugin to activate regardless of the Service being matched.",
      "properties": {
        "id": {
          "type": "string"
        }
      },
      "type": "object"
    }
  }
}

관련 리소스

더 알아보기 (Learn more)