continue
- log_of_kong_api_gateway-8.md
- https://gist.github.com/takurx/45164aa6bb4269d50ef07bcce6a62403
reference
- Kong Gateway利用手順書(1.1.0版)2023年03月01日一般社団法人データ社会推進協議会
- https://data-society-alliance.org/wp-content/uploads/2023/03/Kong%E5%88%A9%E7%94%A8%E6%89%8B%E9%A0%86%E6%9B%B8_20230301_v1.1.0.pdf
- KONGことはじめ #Kong - Qiita
- https://qiita.com/AkihiroTakamura/items/f3dbcace4a9e6ca982a1
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'name=key-auth' "http://[kong host name]:8001/apis/mockbin/plugins/"
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" \
-d 'name=key-auth' "http://[kong host name]:8001/apis/mockbin/plugins/"
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" \
-d 'name=key-auth' "http://localhost:8001/apis/fiware_mock/plugins/"
chino@chino-Legion-5-15IAH7H:~$ curl -X POST -H "Content-Type: application/x-www-form-urlencoded" \
> -d 'name=key-auth' "http://localhost:8001/apis/fiware_mock/plugins/"
{"message":"Not found"}
curl -X GET http://54.238.24.118:4061/version
curl -i -X POST ¥
--url http://example.kong-gateway.com:8001/services/orion-service/plugins/ ¥
--data 'name=key-auth
curl -i -X POST \
--url 'http://localhost:8001/services/fiware_service/plugins/' \
--data 'name=key-auth'
chino@chino-Legion-5-15IAH7H:~$ curl -i -X POST \
> --url 'http://localhost:8001/apis/fiware_mock/plugins/' \
> --data 'name=key-auth'
HTTP/1.1 404 Not Found
Date: Mon, 15 Jul 2024 09:40:59 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 38818342186ec0282042c25e31fde322
Content-Length: 23
X-Kong-Admin-Latency: 5
Server: kong/3.7.0.0-enterprise-edition
{"message":"Not found"}
chino@chino-Legion-5-15IAH7H:~$ curl -i -X POST \
> --url 'http://localhost:8001/services/fiware_service/plugins/' \
> --data 'name=key-auth'
HTTP/1.1 201 Created
Date: Mon, 15 Jul 2024 09:45:25 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 0d6bd25645e85101c6978816aa085e72
Content-Length: 511
X-Kong-Admin-Latency: 21
Server: kong/3.7.0.0-enterprise-edition
{"name":"key-auth","consumer":null,"ordering":null,"created_at":1721036725,"id":"05a26594-9bfa-402a-958c-2767f6cb70ad","instance_name":null,"config":{"key_in_body":false,"realm":null,"key_in_header":true,"hide_credentials":false,"key_names":["apikey"],"run_on_preflight":true,"anonymous":null,"key_in_query":true},"protocols":["grpc","grpcs","http","https","ws","wss"],"enabled":true,"tags":null,"route":null,"updated_at":1721036725,"consumer_group":null,"service":{"id":"8fae5e2c-60ba-4cdb-ba9a-b9ba0ffbf12b"}}
chino@chino-Legion-5-15IAH7H:~$
chino@chino-Legion-5-15IAH7H:~$ curl -X GET http://localhost:8000/fiware_mock/version
{
"message":"No API key found in request",
"request_id":"51c7a7543b2dd70c47855e5cab40b51d"
}
chino@chino-Legion-5-15IAH7H:~$ echo '{"name":"key-auth","consumer":null,"ordering":null,"created_at":1721036725,"id":"05a26594-9bfa-402a-958c-2767f6cb70ad","instance_name":null,"config":{"key_in_body":false,"realm":null,"key_in_header":true,"hide_credentials":false,"key_names":["apikey"],"run_on_preflight":true,"anonymous":null,"key_in_query":true},"protocols":["grpc","grpcs","http","https","ws","wss"],"enabled":true,"tags":null,"route":null,"updated_at":1721036725,"consumer_group":null,"service":{"id":"8fae5e2c-60ba-4cdb-ba9a-b9ba0ffbf12b"}}' | jq .
{
"name": "key-auth",
"consumer": null,
"ordering": null,
"created_at": 1721036725,
"id": "05a26594-9bfa-402a-958c-2767f6cb70ad",
"instance_name": null,
"config": {
"key_in_body": false,
"realm": null,
"key_in_header": true,
"hide_credentials": false,
"key_names": [
"apikey"
],
"run_on_preflight": true,
"anonymous": null,
"key_in_query": true
},
"protocols": [
"grpc",
"grpcs",
"http",
"https",
"ws",
"wss"
],
"enabled": true,
"tags": null,
"route": null,
"updated_at": 1721036725,
"consumer_group": null,
"service": {
"id": "8fae5e2c-60ba-4cdb-ba9a-b9ba0ffbf12b"
}
}
curl -i -X POST ¥
--url http://example.kong-gateway.com:8001/consumers/ ¥
--data 'username=TestUser'
curl -i -X POST \
--url http://localhost:8001/consumers/ \
--data 'username=TestUser'
chino@chino-Legion-5-15IAH7H:~$ curl -i -X POST \
> --url http://localhost:8001/consumers/ \
> --data 'username=TestUser' | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 198 100 181 100 17 11312 1062 --:--:-- --:--:-- --:--:-- 12375
parse error: Invalid numeric literal at line 1, column 9
chino@chino-Legion-5-15IAH7H:~$ curl -i -X POST \
> --url http://localhost:8001/consumers/ \
> --data 'username=TestUser'
HTTP/1.1 409 Conflict
Date: Mon, 15 Jul 2024 09:51:30 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 96482d66ccf55b50d4a15e43113b0649
Content-Length: 147
X-Kong-Admin-Latency: 16
Server: kong/3.7.0.0-enterprise-edition
{"name":"unique constraint violation","code":5,"message":"UNIQUE violation detected on '{username=\"TestUser\"}'","fields":{"username":"TestUser"}}
curl -i -X POST ¥
--url http://example.kong-gateway.com:8001/consumers/TestUser/key-auth
curl -i -X POST \
--url http://localhost:8001/consumers/TestUser/key-auth
chino@chino-Legion-5-15IAH7H:~$ curl -i -X POST \
> --url http://localhost:8001/consumers/TestUser/key-auth
HTTP/1.1 201 Created
Date: Mon, 15 Jul 2024 09:53:25 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 17c37d6ff820b76a47175d439e7d0720
Content-Length: 190
X-Kong-Admin-Latency: 18
Server: kong/3.7.0.0-enterprise-edition
{"tags":null,"consumer":{"id":"2246b12c-e7ec-4f38-942e-3b1948c00e6c"},"created_at":1721037205,"id":"041690ac-217c-4959-9b4b-350cbc3c2a35","ttl":null,"key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
curl -i -X GET http://example.kong-gateway.com:8000/orion/version?apikey=<認証キー>
curl -i -X GET http://localhost:8000/fiware_mock/version?apikey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
chino@chino-Legion-5-15IAH7H:~$ curl -i -X GET http://localhost:8000/fiware_mock/version?apikey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 68
Connection: keep-alive
X-Powered-By: Express
Fiware-Correlator: e5ddf6aa-de84-4ae8-85ca-3b5827d4b50f
ETag: W/"44-+fNGoUfpYl7QYTxK6uAPTQVuu6s"
Date: Mon, 15 Jul 2024 09:55:23 GMT
X-Kong-Upstream-Latency: 29
X-Kong-Proxy-Latency: 5
Via: kong/3.7.0.0-enterprise-edition
X-Kong-Request-Id: 3b14b8775c6a3c777e4e7a471556a02b
{"libVersion":"2.21.0","port":4041,"baseRoot":"/","version":"1.2.5"}