-
Notifications
You must be signed in to change notification settings - Fork 0
/
envoy-minimal.yml
101 lines (101 loc) · 4.82 KB
/
envoy-minimal.yml
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
static_resources:
listeners:
- name: main
address:
socket_address:
address: 0.0.0.0 # Listen on every ip on every interface
port_value: 80 # Listen on port 80
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
codec_type: auto
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: web_service # Here you would specify your downstream service cluster
http_filters:
- name: envoy.filters.http.wasm
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
config:
name: "jwt_auth"
root_id: "jwt_auth"
configuration:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
introspect_endpoint:
authority: "id.example.com"
path: "/oauth2/introspect"
upstream: "oauth2-authorization-serve"
jwt:
key: 'Generate new key with command "openssl genpkey -algorithm ed25519"'
output_header_name: "X-JWT-User"
algorithm: "EdDSA"
jsonnet_template: |-
function(introspect_json) {
// If expiration is not set, set it to 0 to make it invalid
exp: if(std.objectHas(introspect_json, "exp")) then introspect_json.exp else 0,
iat: if(std.objectHas(introspect_json, "iat")) then introspect_json.iat,
nbf: if(std.objectHas(introspect_json, "nbf")) then introspect_json.nbf,
iss: if(std.objectHas(introspect_json, "iss")) then introspect_json.iss,
// If supplied aud is not an array convert it to one with 1 element.
aud: if(std.objectHas(introspect_json, "aud")) then (if(std.isArray(introspect_json.aud)) then introspect_json.aud else [introspect_json.aud]),
jti: if(std.objectHas(introspect_json, "jti")) then introspect_json.jti,
sub: if(std.objectHas(introspect_json, "sub")) then introspect_json.sub
}
vm_config:
runtime: "envoy.wasm.runtime.v8"
code:
local:
filename: "PATH_TO_BUILT_FILTER.wasm" # <--- REPLACE
allow_precompiled: true
- name: envoy.filters.http.router
clusters:
- name: web_service # Here you would configure your downstream service cluster
connect_timeout: 30.0s
type: STRICT_DNS
lb_policy: round_robin
load_assignment:
cluster_name: web_service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: web_service
port_value: 5678
- name: oauth2-authorization-serve # Here you would configure your introspection endpoint service
connect_timeout: 15.0s # Should be way less than 50ms in prod.
type: STRICT_DNS
lb_policy: round_robin
load_assignment:
cluster_name: oauth2-authorization-serve
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: id.example.com
port_value: 80 # or 443
# If your introspect endpoint is HTTPS only (which it should be)
# http2_protocol_options: {}
# 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:
# match_subject_alt_names:
# - exact: "id.example.com"
# trusted_ca:
# filename: /cluster-ca.pem