External Authorization
This filter should be configured with the name envoy.filters.http.ext_authz.
The external authorization filter calls an external gRPC or HTTP service to check whether an incoming HTTP request is authorized or not. If the request is deemed unauthorized, then the request will be denied normally with 403 (Forbidden) response. Note that sending additional custom metadata from the authorization service to the upstream, to the downstream or to the authorization service is also possible. This is explained in more details at .
The content of the requests that are passed to an authorization service is specified by CheckRequest.
The HTTP filter, using a gRPC/HTTP service, can be configured as follows. You can see all the configuration options at .
A sample filter configuration for a gRPC authorization server:
- name: ext-authz
type: static
typed_extension_protocol_options:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
"@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicit_http_config:
http2_protocol_options: {}
load_assignment:
cluster_name: ext-authz
endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 10003
# entire request.
connect_timeout: 0.25s
Note
One of the features of this filter is to send HTTP request body to the configured gRPC authorization server as part of the check request.
A sample configuration is as follows:
Please note that by default carries the HTTP request body as UTF-8 string and it fills the body field. To pack the request body as raw bytes, it is needed to set field to true. In effect to that, the raw_body field will be set and field will be empty.
A sample filter configuration for a raw HTTP authorization server:
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: 127.0.0.1:10003
cluster: ext-authz
timeout: 0.25s
failure_mode_allow: false
route_config:
name: local_route
virtual_hosts:
domains: ["*"]
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: local_service
routes:
- match: { prefix: "/static" }
route: { cluster: some_service }
typed_per_filter_config:
envoy.filters.http.ext_authz:
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute
disabled: true
- match: { prefix: "/" }
The HTTP filter outputs statistics in the cluster.<route target cluster>.ext_authz. namespace.
The External Authorization filter supports emitting dynamic metadata as an opaque google.protobuf.Struct
.
When using a gRPC authorization server, dynamic metadata will be emitted only when the CheckResponse contains a filled field.
When using an HTTP authorization server, dynamic metadata will be emitted only when there are response headers from the authorization server that match the configured dynamic_metadata_from_headers, if set. For every response header that matches, the filter will emit dynamic metadata whose key is the name of the matched header and whose value is the value of the matched header.
The fraction of requests for which the filter is enabled can be configured via the value of the filter_enabled field.