Skip to content
Kong Docs are moving soon! Our docs are migrating to a new home. You'll be automatically redirected to the new site in the future. In the meantime, view this page on the new site!
Kong Logo | Kong Docs Logo
  • Docs
    • Explore the API Specs
      View all API Specs View all API Specs View all API Specs arrow image
    • Documentation
      API Specs
      Kong Gateway
      Lightweight, fast, and flexible cloud-native API gateway
      Kong Konnect
      Single platform for SaaS end-to-end connectivity
      Kong AI Gateway
      Multi-LLM AI Gateway for GenAI infrastructure
      Kong Mesh
      Enterprise service mesh based on Kuma and Envoy
      decK
      Helps manage Kong’s configuration in a declarative fashion
      Kong Ingress Controller
      Works inside a Kubernetes cluster and configures Kong to proxy traffic
      Kong Gateway Operator
      Manage your Kong deployments on Kubernetes using YAML Manifests
      Insomnia
      Collaborative API development platform
  • Plugin Hub
    • Explore the Plugin Hub
      View all plugins View all plugins View all plugins arrow image
    • Functionality View all View all arrow image
      View all plugins
      AI's icon
      AI
      Govern, secure, and control AI traffic with multi-LLM AI Gateway plugins
      Authentication's icon
      Authentication
      Protect your services with an authentication layer
      Security's icon
      Security
      Protect your services with additional security layer
      Traffic Control's icon
      Traffic Control
      Manage, throttle and restrict inbound and outbound API traffic
      Serverless's icon
      Serverless
      Invoke serverless functions in combination with other plugins
      Analytics & Monitoring's icon
      Analytics & Monitoring
      Visualize, inspect and monitor APIs and microservices traffic
      Transformations's icon
      Transformations
      Transform request and responses on the fly on Kong
      Logging's icon
      Logging
      Log request and response data using the best transport for your infrastructure
  • Support
  • Community
  • Kong Academy
Get a Demo Start Free Trial
decK
  • Home icon
  • decK
  • Gateway
  • Configuring Authentication
github-edit-pageEdit this page
report-issueReport an issue
  • Kong Gateway
  • Kong Konnect
  • Kong Mesh
  • Kong AI Gateway
  • Plugin Hub
  • decK
  • Kong Ingress Controller
  • Kong Gateway Operator
  • Insomnia
  • Kuma

  • Docs contribution guidelines
  • Introduction
    • Overview
    • Configuration Options
    • Support Policy
    • Security Policy
  • Changelog
  • Installation
    • Overview
    • Binary
    • Docker
    • GitHub Actions
  • Get Started
  • Managing Kong Gateway
    • Overview
    • Konnect Configuration
    • Configure Authentication
    • Ping
    • Backup
    • Diff
    • Sync
    • Apply
    • Reset
    • Validate
    • RBAC
    • Workspaces
    • Tags
    • De-duplicate Plugin Configuration
    • Object Defaults
    • Sensitive Data
  • decK Files
    • Overview
    • Config Generation
      • openapi2kong
      • kong2kic
      • kong2tf
    • Linting
    • File Manipulation
      • Overview
      • Update Values
      • Plugins
      • Tags
      • Namespace
    • Combining Files
      • Merge
      • Render
    • Validate
    • Convert
  • APIOps
    • Overview
    • Continuous Integration
    • Federated Config
  • Reference
    • Entities
    • FAQ
    • Gateway 3.0 Upgrade
    • Environment Variables
enterprise-switcher-icon Switch to OSS
On this pageOn this page
  • Token authentication
  • Certificate authentication
  • OpenID Connect authentication

Configuring Authentication

decK assumes that it is running on the same machine as Kong Gateway and that the Admin API requires no authentication by default.

This page explains the CLI flags required to customise this behavior. If you would like to change the default behavior using environment variables or a configuration file, see the configuration options page.

The following examples use deck gateway ping, but the flags also apply to all other deck gateway commands.

The --kong-addr flag configures the URL that decK calls to use the Admin API. The default value is http://localhost:8001.

deck gateway ping --kong-addr https://my-kong-gateway.example.com:8001

If you run Kong Gateway using a self-signed TLS certificate, you should specify the --ca-cert (raw contents) or --ca-cert-file flag so that TLS verification can be performed:

deck gateway ping --kong-addr https://my-kong-gateway.example.com:8001 --ca-cert-file /path/to/ca.crt

If you don’t want to verify the TLS certificate (we do not recommend this), you can use the --tls-skip-verify flag.

Token authentication

If your Admin API is secured using RBAC, you will need to send the Kong-Admin-Token header in your requests. This is done using the --headers flag:

deck gateway ping --headers "Kong-Admin-Token:$MY_TOKEN_HERE"

Certificate authentication

If your Admin API is secured using mutual TLS, you need to send a TLS client certificate and key:

deck gateway ping --tls-client-cert-file /path/to/tls.crt --tls-client-cert-key /path/to/tls.key

You may also specify the raw contents of these files as --tls-client-cert $CERT and --tls-client-key $KEY

OpenID Connect authentication

If your Admin API is secured using OpenID Connect, you will need to call the Kong Manager /auth endpoint and save the cookies to use with --kong-cookie-jar-path.

To generate a session cookie, you can use the following script. Ensure that you change the KONG_ADMIN_URL, KONG_ADMIN_USER, KONG_IDP_USER and KONG_IDP_PASS values at the top.

#!/usr/bin/env bash

# halt on errors
set -e

# The admin URL for Kong
KONG_ADMIN_URL=https://my-kong.example.com

# The admin user for Kong
# This user should be the one associated with
# the IDP user
KONG_ADMIN_USER=jdoe

# The IDP user of the person initiating
# the pipeline job
KONG_IDP_USER=jdoe@your-idp.com
# The corresponding password for the IDP user
KONG_IDP_PASS=********

# The Kong workspace we want to use
KONG_WORKSPACE=default

# Create restrictive temp directory for session cookie
TMPDIR=$(mktemp -d -t ci-XXXXXXXXXX)
chmod 700 "${TMPDIR}"

# A temporary file used for storing the Kong
# manager session cookie
COOKIE_JAR=$(mktemp "${TMPDIR}/cookie.jar.XXXX")

# Chmod the cookie jar file path to stop access from other users
# on the same system
chmod 600 "${COOKIE_JAR}"

# Create a unique user agent name for this request
# This exact name is used when creating the session cookie
# if you try to reuse the cookie without this name or a different user-agent
# name then the signature validation will fail. And the cookie will not be
# usable.
# The UNIQUE_USER_AGENT variable is generated by uuidgen and only ever stored
# in memory.
UNIQUE_USER_AGENT=$(uuidgen)

# Function to call delete on the auth endpoint
# this will destroy the cookie in the Kong database
function auth_logout() {
  curl -s -X DELETE --cookie "${COOKIE_JAR}" --cookie-jar "${COOKIE_JAR}" \
	-A "${UNIQUE_USER_AGENT}" \
	-H "Kong-Admin-User: ${KONG_ADMIN_USER}" \
	"${KONG_ADMIN_URL}/auth?session_logout=true"
}

# Function to remove the cookie file from the filesystem
function remove_cookie() {
  if [ -d "${TMPDIR}" ]; then
	/usr/bin/rm -rf "${TMPDIR}"
  fi
}

# On any interrupt, error or normal exit remove the cookie jar folder
# and call auth_logout
trap \
  "{ auth_logout; remove_cookie ; exit 0; }" \
  SIGINT SIGTERM ERR EXIT

# By hitting the /auth endpoint of Kong admin API
# we can simulate a Kong Manager login and store
# the session cookie that is returned.
# To do this we pass the Kong admin user name, the
# IDP user name and the IDP password.
curl -s -k --get --cookie "${COOKIE_JAR}" --cookie-jar "${COOKIE_JAR}" \
  -A "${UNIQUE_USER_AGENT}" \
  -H "Kong-Admin-User: ${KONG_ADMIN_USER}" \
  -u ${KONG_IDP_USER}:${KONG_IDP_PASS} \
  ${KONG_ADMIN_URL}/auth

# decK now has a session cookie it can use when talking to the admin api.
# The decK command passes the kong-admin-user and user-agent headers
# without both of these headers set to the correct value the deck commands
# session cookie will fail validation
deck gateway ping \
  --workspace "${KONG_WORKSPACE}" \
  --kong-addr "${KONG_ADMIN_URL}" \
  --kong-cookie-jar-path "${COOKIE_JAR}" \
  --headers "kong-admin-user:${KONG_ADMIN_USER}" \
  --headers "user-agent:${UNIQUE_USER_AGENT}" \
  --yes
Thank you for your feedback.
Was this page useful?
Too much on your plate? close cta icon
More features, less infrastructure with Kong Konnect. 1M requests per month for free.
Try it for Free
  • Kong
    Powering the API world

    Increase developer productivity, security, and performance at scale with the unified platform for API management, service mesh, and ingress controller.

    • Products
      • Kong Konnect
      • Kong Gateway Enterprise
      • Kong Gateway
      • Kong Mesh
      • Kong Ingress Controller
      • Kong Insomnia
      • Product Updates
      • Get Started
    • Documentation
      • Kong Konnect Docs
      • Kong Gateway Docs
      • Kong Mesh Docs
      • Kong Insomnia Docs
      • Kong Konnect Plugin Hub
    • Open Source
      • Kong Gateway
      • Kuma
      • Insomnia
      • Kong Community
    • Company
      • About Kong
      • Customers
      • Careers
      • Press
      • Events
      • Contact
  • Terms• Privacy• Trust and Compliance
© Kong Inc. 2025