Hello Yan, I did this but nothing happened, when I send a message on websocket session the filter ext_proc is not called. Bellow is my yaml config to envoy.
admin:
access_log_path: "/tmp/admin_access.log"
address:
socket_address:
address: "0.0.0.0"
port_value: 9901
static_resources:
listeners:
- name: "pdv-envoy"
address:
socket_address:
address: "0.0.0.0"
port_value: 8081
traffic_direction: INBOUND
filter_chains:
- filters:
- name: "envoy.filters.network.http_connection_manager"
typed_config:
upgrade_configs:
- upgrade_type: "websocket"
- filters:
- name: envoy.filters.http.ext_proc
typed_config:
grpc_service:
google_grpc:
stat_prefix: ext_authz
timeout: 1.5s
- name: "envoy.filters.http.router"
stat_prefix: "ingress"
generate_request_id: true
codec_type: "auto"
route_config:
name: "pdv-route-ingress"
virtual_hosts:
- name: "pdv-service-ingress"
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: "app"
cors:
allow_origin_string_match:
prefix: "*"
allow_methods: "GET, PUT, DELETE, POST, PATCH, OPTIONS"
allow_headers: "authorization, keep-alive, user-agent, cache-control, content-type, content-transfer-encoding, x-accept-content-transfer-encoding, x-accept-response-streaming, x-user-agent, x-grpc-web, referer"
expose_headers: "grpc-status, grpc-message, x-envoy-upstream-service-time"
http_filters:
- name: envoy.filters.http.cors
- name: envoy.filters.http.jwt_authn
typed_config:
providers:
jwt_provider:
payload_in_metadata: jwt_payload
remote_jwks:
http_uri:
cluster: jwt_certs
timeout: 5s
cache_duration:
seconds: 300
rules:
- match:
safe_regex:
google_re2: {}
regex: ^\/((health)|(ws\/.*)|(docs)|(redoc)|(openapi.json)|(service/metrics))(\/){0,1}$
- match:
prefix: "/"
requires:
provider_name: jwt_provider
- name: envoy.filters.http.ext_authz
typed_config:
with_request_body:
max_request_bytes: 8192
allow_partial_message: true
failure_mode_allow: false
transport_api_version: "v3"
grpc_service:
google_grpc:
stat_prefix: ext_authz
timeout: 1.5s
- name: envoy.filters.http.lua
typed_config:
inline_code: |
function envoy_on_request(request_handle)
request_handle:logErr("ENNNVOOOYYY")
local meta = request_handle:streamInfo():dynamicMetadata()
for key, value in pairs(meta) do
request_handle:headers():add("client-id", value.jwt_payload.client_id)
end
end
- name: "envoy.filters.http.router"
clusters:
- name: "jwt_certs"
connect_timeout: "5s"
type: LOGICAL_DNS
dns_lookup_family: "V4_PREFERRED"
load_assignment:
cluster_name: "jwt_certs"
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
port_value: 443
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
- name: "cluster_http"
connect_timeout: "0.25s"
type: STRICT_DNS
load_assignment:
cluster_name: "cluster_http"
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: "127.0.0.1"
port_value: 8081
- name: "app"
connect_timeout: "0.25s"
type: STRICT_DNS
load_assignment:
cluster_name: "app"
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: "127.0.0.1"
port_value: 8281