Skip to content
VERIFY THAT REQUESTS TO A SERVICE ARE CACHED IN KONG FOR A SPECIFIC CONSUMER

icon picker
Review: Enable Key-Auth + Provision a Consumer

In a previous lab, you learned how to enable the Key-Auth plugin and provision a Consumer, use the following commands to quickly:
Add the Key-Auth plugin
Add a Consumer to Kong
Provision key credentials for your consumer
Verify that the consumer credentials are valid

Use the following http commands to quickly enable the key-auth plugin on the httpbin service and configure consumer named Jason with an apikey of jasonkey
# Add the Key-Auth Plugin
http post localhost:8001/services/httpbin/plugins \
name=key-auth

# Add a Consumer
http post localhost:8001/consumers \
username=Jason

# Provision key credentials for your Consumer
http post localhost:8001/consumers/Jason/key-auth \
key=jasonkey

# Verify that your Consumer credentials are valid
http get localhost:8000/ \
host:example.com \
apikey:jasonkey
Response
The response should look similar to this:
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 523
Content-Type: application/json
Server: gunicorn/19.9.0
X-Cache-Key: 9236523725fec746b7c0ad7dadeed365
X-Cache-Status: Miss
X-Kong-Proxy-Latency: 112
X-Kong-Upstream-Latency: 9

{
"args": {},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Apikey": "jasonkey",
"Connection": "close",
"Host": "httpbin.org",
"User-Agent": "HTTPie/1.0.2",
"X-Consumer-Id": "1264dcd7-1525-4272-90ab-aa17785e7811",
"X-Consumer-Username": "Jason",
"X-Forwarded-Host": "example.com"
},
"json": null,
"method": "GET",
"origin": "172.19.0.1, 52.201.239.166",
"url": "http://example.com/anything"
}

Next Section

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.