FreeKB - create acl Plugin using curl
Kong - create acl Plugin using curl

The curl POST command can be used to configure a plugin. A plugin can be associated with a service or a route, thus this assumes you have already created the service or route that you want to associate the plugin with.


On the Kong server

If Kong is running on docker, refer to Kong - Docker container command line for the steps on how to issue commands in the Kong Docker container. Assuming you are using the default kong.conf file, the Kong Admin API will listen on port 8001.

If issuing this command on the Kong server, this command will configure the acl plugin for example-service.

curl -X POST "http://localhost:8001/services/example-service/plugins" --data "name=acl" --data "config.whitelist=example-group" --data "config.hide_groups_header=true"

 

This command will configure the acl plugin for example-route.

curl -X POST "http://localhost:8001/routes/example-route/plugins" --data "name=acl" --data "config.whitelist=example-group" --data "config.hide_groups_header=true"

 


From a remote server

If issuing this command from a remote server, this command will configure the acl plugin for example-service.

curl -X POST "http://hostname:8000/admin-api/services/example-service/plugins" --data "name=acl" --data "config.whitelist=example-group" --data "config.hide_groups_header=true"

 

This command will configure the acl plugin for example-route.

curl -X POST "http://hostname:8000/admin-api/routes/example-route/plugins" --data "name=acl" --data "config.whitelist=example-group" --data "config.hide_groups_header=true"

 


Validation

If the plugin was successfully configured, something like this should be displayed. Additionally, the cURL command can be used to ensure the plugin exists.

{
 "created_at":1585020145,
 "config":{
           "hide_groups_header":true,
           "blacklist":null,
           "whitelist":["example-group"]},
           "id":"62d77992-e3f2-458c-a3a7-38150504c7d9",
           "service":{"id":"1a653c60-0d39-4838-a6ed-d47314b1c05e"},
           "enabled":true,
           "protocols":["grpc","grpcs","http","https"],
           "name":"acl",
           "consumer":null,
           "route":null,
           "tags":null
}

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 78563 in the box below so that we can be sure you are a human.




Comments