-
Notifications
You must be signed in to change notification settings - Fork 0
/
envoy-proxy.yaml
192 lines (191 loc) · 7.19 KB
/
envoy-proxy.yaml
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
apiVersion: v1
kind: ConfigMap
metadata:
name: envoy
labels:
app: authorino
data:
envoy.yaml: |
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 8000
filter_chains:
- filters:
- name: envoy.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: local
route_config:
name: authn_authz
virtual_hosts:
- name: edge
domains: ['edge.kafka.*']
typed_per_filter_config:
envoy.filters.http.ext_authz:
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute
check_settings:
context_extensions:
virtual_host: edge
envoy.filters.http.lua:
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.LuaPerRoute
name: wristband.lua
routes:
- match:
path: /token
headers: [{ name: ":method", exact_match: "GET" }]
direct_response:
status: 200
- name: auth
domains: ['auth.kafka.*']
typed_per_filter_config:
envoy.filters.http.ext_authz:
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute
check_settings:
context_extensions:
virtual_host: auth
envoy.filters.http.lua:
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.LuaPerRoute
name: permissions.lua
routes:
- match:
path: /check
headers: [{ name: ":method", exact_match: "POST" }]
direct_response:
status: 200
http_filters:
- name: envoy.filters.http.ext_authz
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz
transport_api_version: V3
failure_mode_allow: false
include_peer_certificate: true
grpc_service:
envoy_grpc:
cluster_name: external_auth
timeout: 1s
- name: envoy.filters.http.lua
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
inline_code: |
function envoy_on_response(response_handle)
end
source_codes:
wristband.lua:
inline_string: |
function envoy_on_response(response_handle)
local metadata = response_handle:streamInfo():dynamicMetadata()
local wristband = metadata:get("envoy.filters.http.ext_authz")["wristband"]
response_handle:headers():replace("content-type", "application/json")
response_handle:body(true):setBytes("{\"token\":\""..wristband.."\"}")
end
permissions.lua:
inline_string: |
function table_to_string(tbl)
local result = "{"
for key, val in pairs(tbl) do
result = result.."\""..key.."\""..":"
if type(val) == "table" then
result = result..table_to_string(val)
elseif type(val) == "boolean" then
result = result..tostring(val)
else
result = result.."\""..val.."\""
end
result = result..","
end
if result ~= "" then
result = result:sub(1, result:len()-1)
end
return result.."}"
end
function envoy_on_response(response_handle)
local metadata = response_handle:streamInfo():dynamicMetadata()
local permissions = metadata:get("envoy.filters.http.ext_authz")["permissions"]
response_handle:headers():replace("content-type", "application/json")
response_handle:body(true):setBytes("["..table_to_string(permissions).."]")
end
- name: envoy.filters.http.router
typed_config: {}
use_remote_address: true
clusters:
- name: external_auth
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
http2_protocol_options: {}
load_assignment:
cluster_name: external_auth
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: authorino-authorino-authorization
port_value: 50051
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
common_tls_context:
validation_context:
trusted_ca:
filename: /etc/ssl/certs/authorino-ca-cert.crt
admin:
access_log_path: "/tmp/admin_access.log"
address:
socket_address:
address: 0.0.0.0
port_value: 8001
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: envoy
labels:
app: envoy
spec:
selector:
matchLabels:
app: envoy
template:
metadata:
labels:
app: envoy
spec:
containers:
- name: envoy
image: envoyproxy/envoy:v1.20-latest
command: ["/usr/local/bin/envoy"]
args:
- --config-path /usr/local/etc/envoy/envoy.yaml
- --service-cluster front-proxy
- --log-level info
- --component-log-level filter:trace,http:debug,router:debug
ports:
- name: web
containerPort: 8000
- name: admin
containerPort: 8001
volumeMounts:
- name: config
mountPath: /usr/local/etc/envoy
readOnly: true
- name: authorino-ca-cert
mountPath: /etc/ssl/certs/authorino-ca-cert.crt
readOnly: true
subPath: ca.crt
volumes:
- name: config
configMap:
name: envoy
items:
- key: envoy.yaml
path: envoy.yaml
- name: authorino-ca-cert
secret:
defaultMode: 420
secretName: authorino-ca-cert
replicas: 1