Hi
As per the current order of execution for the bundled plugins, first ACL and then the request-transformer plugin will be executed if both of them I am adding to a service.
For a service I need to customize the plugin execution, I need to execute request-transformer plugin first and then ACL.
How can I achieve it?
The order in which the plugins are executed depends on each plugins’ PRIORITY field, set up on its handler.lua file.
The request-transformer plugin has a priority of 801 while the ACL plugin’s is 950, so ACL will always come first.
A possible solution would be creating a custom plugin: it would be a copy of request-transformer
(named something else, like request-transformer-high-priority
) which is exactly the same as request-transformer
but with a priority higher than 950. Then use that modified plugin instead of the default request-transformer
.
You might want to look at our Plugin Development Guide’s Install Section for details about how to install a custom plugin.
Hi,
I have created a custom plugin same as request-transformer plugin.
handler.lua
local BasePlugin = require “kong.plugins.base_plugin”
local access = require “kong.plugins.kong-custom-plugin.access”
local CustomPluginHandler = BasePlugin:extend()
CustomPluginHandler.PRIORITY = 952
CustomPluginHandler.VERSION = “1.0.0”
function CustomPluginHandler:new()
CustomPluginHandler.super.new(self, “kong-custom-plugin”)
end
function CustomPluginHandler:access(conf)
CustomPluginHandler.super.access(self)
access.execute(conf)
end
return CustomPluginHandler
And I am using the same schema.lua and access.lua files of request-transformer.
The custom plugin created successfully and also I am able to add to a service. However, when I am trying to update the plugin all the plugin fields are displayed. I am only able to see api_id, service_id, route_id and consumer_id.
I should be able to view all the field similar to request-transformer.
What changes required, am I not reading the access.lua properly?
Output of adding plugin:
/etc/kong # curl -i -X POST --url http://localhost:8001/services/example-service/plugins/ --data name=kong-custom-plugin
HTTP/1.1 201 Created
Date: Thu, 28 Mar 2019 14:33:36 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: oO2xfOnJAZREEF9kRyq7BxJal2UhA7P2
Server: kong/0.34-1-enterprise-edition
{“created_at”:1553783616000,"config":{},“id”:“a8459a53-c82e-4bf8-bdac-a9d51696782a”,“enabled”:true,“service_id”:“d8c6891a-877b-4d22-84d0-bebc9b58150f”,“name”:“kong-custom-plugin”}
Note : config is blank