using docker to run the Kong ,I am created the custom Plugin To Validate the header
Key :Test123
---------------------------handler.lua-------------------------------------------
local kong = kong
local CustomPlugin = {
PRIORITY = 1000,
VERSION = “0.1”,
}
function CustomPlugin:access(conf)
CustomPlugin.super.access(self)
– Validate the static header
local header_value = kong.request.get_header(“Key”)
if header_value ~= “Test123” then
– Return an error response if the header is missing or invalid
return kong.response.exit(401, { message = “Unauthorized: Invalid or missing ‘Key’ header” })
end
– If the header is valid, the request will continue to the upstream service
kong.log.debug(“Header validation passed. Continuing to the upstream service.”)
end
return CustomPlugin
--------------------------------------schema--------------------------------------
local typedefs = require “kong.db.schema.typedefs”
return {
name = “custom-plugin”,
fields = {
{ config = {
type = “record”,
fields = {}
}
}
}
}
----------------------------/etc/kong/kong.conf--------------------------------------------
plugins = bundled,custom-plugin
Used cmd
docker cp ./custom-plugin c3b65b77458c:/usr/local/share/lua/5.1/kong/plugins
docker cp ./kong c3b65b77458c:/usr/local/etc
and restart the container but Not working any solution?