Zuplo

API Key Authentication

Secure Your API with API Keys

The Zuplo API Gateway protects your backend API from unauthorized access, abuse, and overload. Add API key authentication to your API in minutes.

Secure Access

Authenticate every request before it reaches your backend.

Control Costs

Set rate limits and quotas to prevent runaway usage.

Ensure Reliability

Shield your backend from overload with traffic management.

How it works

The Zuplo API Gateway sits between your clients and your backend, providing a secure layer of protection and control.

Client
Zuplo API Gateway

Customer VPC

Backend

Step-by-step tutorial

It takes only a few minutes to put Zuplo in front of your backend, adding API key authentication, and configuring your origin to trust requests from Zuplo using JWT verification.

1

Create a Route in Zuplo

First, create a new route in your Zuplo project that will proxy requests to your backend. This route will be the entry point for your API consumers.

Creating a route in Zuplo
Learn how to create routes

📄 OpenAPI native. Import your existing OpenAPI spec to instantly create routes and power your API documentation .

2

Add API Key Authentication Policy

Add the API Key Authentication policy to your route. This policy validates incoming API keys and ensures only authorized consumers can access your API.

Adding API Key Authentication policy in Zuplo
API Key Authentication docs

🔐 Leaked key? No problem. As a GitHub Secret Scanning partner, Zuplo can automatically revoke exposed keys before they can be exploited.

3

Enable the JWT Service Plugin

Enable the JWT Service Plugin in your Zuplo project. This plugin generates JWTs that your origin API can validate, creating a secure trust relationship between Zuplo and your backend.

TypeScriptmodules/zuplo.runtime.ts
export function runtimeInit(runtime: RuntimeExtensions) {
  // Register the JWT Service Plugin
  runtime.addPlugin(new JwtServicePlugin());
}
JWT Service Plugin docs
4

Secure Your API with JWT Authentication

Configure your backend to validate the JWTs issued by Zuplo. This ensures that only requests coming through your Zuplo gateway are accepted.

lua
-- Make sure to install and configure the required plugins in Kong: 'jwt' and 'jwt-keyset'.
-- Add the JWKS URI and other configurations in your service/route configuration.

-- Step 1: Define the service
local service = {
  name = "my_service",
  url = "https://my-api.zuplo.com",
}

-- Step 2: Define the route and enable JWT plugin
local route = {
  service = {
    id = service.id,
  },
  paths = {"/protected"},
  plugins = {
    {
      name = "jwt",
      config = {
        key_claim_name = "kid",
        keyset = {
          name = "my_keyset",
          jwks_uri = "https://my-api-a32f34.zuplo.api/__zuplo/issuer/.well-known/jwks.json",
          cache = true,
          cache_ttl = 600,  -- Cache JWKS for 10 minutes
        },
        algorithms = {"RS256"},
        claims_to_verify = {"exp", "nbf"},
        upstream_headers = {
          ["Authorization"] = "Bearer %s",
        }
      }
    }
  }
}

-- Step 3: Error handling via custom plugins (if needed)
-- For example, log errors, alert, or customize error responses.

-- Example route for demonstration purpose:
-- This is already protected by the JWT plugin specified above.
local function example_handler(self, conf)
  local response = {
    message = "Access granted",
    user = kong.ctx.shared.jwt_claims -- Extracted user claims from the JWT token
  }

  kong.response.exit(200, response)
end

-- Note: This code assumes the necessary setup and configuration in Kong for services,
-- routes, and JWT plugin is appropriately made via the Admin API or declarative config.
5

Call Your API Through Zuplo

Now you can call your API through Zuplo using an API key. The request will be authenticated at the gateway, and a JWT will be forwarded to your backend.

Terminalbash
curl -X GET \
  'https://your-api.zuplo.dev/your-route' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Ready to secure your API?

Get started with Zuplo for free and add API key authentication to your API in minutes.