I want to setup an envoy proxy in front of a backend service to only allow authenticated requests. The authentication is done via a separate auth service with an endpoint /api/v1/authenticate.
With the configuration below, I encountered 2 issues:
- Authentication is only checked for the root path (
localhost:8099/) - The auth service is only called at the root level (localhost:8080/) instead at
/api/v1/authenticate
Now my questions:
- How do I configure envoy so that all requests to the backend service are checked for authentication?
- Is it possible to configure the auth service to be called with a certain path?
admin:
access_log_path: "/dev/null"
address:
socket_address:
address: 0.0.0.0
port_value: 9901
static_resources:
listeners:
- name: main
address:
socket_address:
address: 0.0.0.0
port_value: 8099
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
route_config:
name: service
virtual_hosts:
- name: service
domains: ["*"]
routes:
- match:
prefix: "/"
route:
cluster: service
http_filters:
- name: envoy.filters.http.ext_authz
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz
http_service:
server_uri:
uri: localhost:8080/api/v1/authenticate
cluster: auth
timeout: 5s
failure_mode_allow: false
include_peer_certificate: true
transport_api_version: V3
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
clusters:
- name: service
connect_timeout: 10s
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: httpbin.org
port_value: 80
- name: auth
connect_timeout: 10s
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: auth
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: localhost
port_value: 8080
I am using envoy proxy version 1.23.1.