Skip to content

Instantly share code, notes, and snippets.

@xring
Last active May 30, 2019 03:24
Show Gist options
  • Save xring/19c38cf57929f75ca6add5b7fd6990cb to your computer and use it in GitHub Desktop.
Save xring/19c38cf57929f75ca6add5b7fd6990cb to your computer and use it in GitHub Desktop.
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: inf-auth-gateway-rest
spec:
workloadLabels:
app: istio-ingressgateway
filters:
- listenerMatch:
portNumber: 443
listenerType: GATEWAY
filterName: envoy.lua
filterType: HTTP
insertPosition:
index: FIRST
filterConfig:
inlineCode: |
function process(request_handle, cluster)
local authentication_request = {
[":method"] = "GET",
[":path"] = "/",
[":authority"] = request_handle:headers():get(":authority")
}
authentication_request["authorization"] = request_handle:headers():get("authorization")
local response_headers, response_body = request_handle:httpCall(cluster, authentication_request, "", 100)
if tonumber(response_headers[":status"]) ~= 200 then
request_handle:respond({[":status"] = response_headers[":status"]}, response_body)
end
end
function envoy_on_request(request_handle)
process(request_handle, "outbound_.80_._.inf-auth-gateway-rest.x.svc.cluster.local")
end
function envoy_on_response(response_handle)
response_handle:headers():add("x-supported-by", "xring.info")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment