Meta description: Secure and throttle your APIs with Kong: key-auth, Basic auth, JWT, ACL, rate limiting, request size limiting and IP restriction.
What you'll learn
How plugins work and where they apply
Authentication vs authorization
Ways to authenticate
How to limit traffic fairly
What is a plugin?
A plugin adds behavior to the request/response flow without changing your backend code. You can attach it at different scopes:
Scope Applies to
Global Every request through Kong
Service All routes of one service
Route Only one route
Consumer Only one caller
When scopes overlap, the more specific one wins.
Part 1: Authentication, "who are you?"
Key authentication ( key-auth )
The simplest approach. The client sends a secret key in a header.
# 1. Enable on a service curl -X POST http://localhost:8001/services/alpha-service/plugins --data name = key-auth
# 2. Create a key for the consumer curl -X POST http://localhost:8001/consumers/asha/key-auth --data key = asha-secret-key
# 3.…