-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
130 lines (102 loc) · 4.45 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
SHELL := /bin/bash
install_kong_stander_routine_docker:
docker network create kong-net || true
docker run -d --name kong-database \
--network=kong-net \
-p 5432:5432 \
-e "POSTGRES_USER=kong" \
-e "POSTGRES_DB=kong" \
-e "POSTGRES_PASSWORD=kongpass" \
postgres:13
docker run --rm --network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_PASSWORD=kongpass" \
-e "KONG_PASSWORD=test" \
kong/kong-gateway:latest kong migrations bootstrap
docker run -d --name kong-gateway \
--network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_USER=kong" \
-e "KONG_PG_PASSWORD=kongpass" \
-e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
-e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
-e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_LISTEN=0.0.0.0:8001" \
-e "KONG_ADMIN_GUI_URL=http://localhost:8002" \
-e KONG_LICENSE_DATA \
-p 8000:8000 \
-p 8443:8443 \
-p 8001:8001 \
-p 8444:8444 \
-p 8002:8002 \
-p 8445:8445 \
-p 8003:8003 \
-p 8004:8004 \
kong/kong-gateway:latest
sleep 4
curl -i -X GET --url http://localhost:8001/services
remove_kong_stander_routine:
docker kill kong-gateway || true
docker kill kong-database || true
docker container rm kong-gateway || true
docker container rm kong-database || true
docker network rm kong-net || true
start_kong_with_custom_plugins:
# remove old
clear
curl -s https://get.konghq.com/quickstart | bash -s -- -d -a kong-quickstart
# build new image
docker build -t kong-gateway_my-plugin:3.8-0.0.1 .
# start kong with custom plugin
chmod +x quickstart && ./quickstart -r "" -i kong-gateway_my-plugin -t 3.8-0.0.1
# curl -Ls https://get.konghq.com/quickstart | bash -s -- -r "" -i kong-gateway_my-plugin -t 3.8-0.0.1
sleep 4
# create service
curl -i -s -X POST http://localhost:8001/services --data 'name=service1' --data 'url=http://host.docker.internal:5500'
curl -i -s -X POST http://localhost:8001/services --data 'name=service2' --data 'url=http://host.docker.internal:5500'
# create route for service
curl -i -X POST http://localhost:8001/services/service1/routes --data 'paths[]=/mock1' --data 'name=route1'
curl -i -X POST http://localhost:8001/services/service2/routes --data 'paths[]=/mock2' --data 'name=route2'
# Create a new consumer
curl -i -X POST http://localhost:8001/consumers/ --data 'username=consumer1'
# Assign the consumer a key
curl -i -X POST http://localhost:8001/consumers/consumer1/key-auth --data 'key=eyJzdm4iOiIxIiwicmVwb3J0X2RhdGEiOiJkR1Z6ZEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQT09In0'
# add plugin to route
curl -i -s -X POST http://localhost:8001/routes/route1/plugins --data 'name=attest'
curl -i -X POST http://localhost:8001/routes/route2/plugins --data "name=tee-auth" --data "instance_name=tee-auth-route2" --data "config.key_names=apikey"
sleep 4
# test attest plugin
# no config
curl -i http://localhost:8000/mock1
# get ng evidence
curl -i http://localhost:8000/mock1 -H 'ng_auth:true'
# attest service evidence
curl -i http://localhost:8000/mock1 -H 'api:service1'
# all func test
curl -i http://localhost:8000/mock1 -H 'api:service1' -H 'ng_auth:true'
# test tee-auth plugin
curl -i http://localhost:8000/mock2 -H 'apikey:eyJzdm4iOiIxIiwicmVwb3J0X2RhdGEiOiJkR1Z6ZEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQT09In0' -H 'tee:sample'
kong_build:
# remove old
clear
curl -s https://get.konghq.com/quickstart | bash -s -- -d -a kong-quickstart
# build new image
docker build -t kong-gateway_my-plugin:3.8-0.0.1 .
# start kong with custom plugin
chmod +x ./quickstart && ./quickstart -r "" -i kong-gateway_my-plugin -t 3.8-0.0.1
# curl -Ls https://get.konghq.com/quickstart | bash -s -- -r "" -i kong-gateway_my-plugin -t 3.8-0.0.1
sleep 4
# start sample service
python3 /root/ActivatePro/Service/HelloService.py &
# create service
curl -i -s -X POST http://localhost:8001/services --data 'name=ngattestservice' --data 'url=http://host.docker.internal:6005'
# create route for service
curl -i -X POST http://localhost:8001/services/ngattestservice/routes --data 'paths[]=/ngattestmock' --data 'name=ngattestroute'
# add plugin to route
curl -i -s -X POST http://localhost:8001/routes/ngattestroute/plugins --data 'name=attest'
sleep 4
# all func test
curl -i http://localhost:8000/ngattestmock -H 'ng_auth:true'