lua.ingress_client_name_header.lua Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of envoy-control-core Show documentation
Show all versions of envoy-control-core Show documentation
Production-ready Control Plane for Service Mesh based on Envoy Proxy.
function envoy_on_request(handle)
local streamInfo = handle:streamInfo()
local trusted_header_name = handle:metadata():get("trusted_client_identity_header") or ""
if trusted_header_name == "" then
return
end
if handle:headers():get(trusted_header_name) ~= nil then
handle:headers():remove(trusted_header_name)
end
if handle:connection():ssl() and streamInfo:downstreamSslConnection() then
local uriSanPeerCertificate = handle:streamInfo():downstreamSslConnection():uriSanPeerCertificate()
if uriSanPeerCertificate ~= nil and next(uriSanPeerCertificate) ~= nil then
local san_uri_format = handle:metadata():get("san_uri_lua_pattern")
for _, entry in pairs(uriSanPeerCertificate) do
local clientName = string.match(entry, san_uri_format)
if clientName ~= nil and clientName ~= '' then
handle:headers():add(trusted_header_name, clientName)
end
end
end
end
end
function envoy_on_response(handle)
end