Skip to content

Commit

Permalink
feat: add category for every plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
smileby committed Dec 26, 2023
1 parent 6701b19 commit 193b798
Show file tree
Hide file tree
Showing 90 changed files with 615 additions and 28 deletions.
9 changes: 9 additions & 0 deletions apisix/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,13 @@ return {
["/stream_routes"] = true,
["/plugin_metadata"] = true,
},
-- plugin category enum
PLUGIN_CATEGORY_GENERAL = "General",
PLUGIN_CATEGORY_TRANSFORMATION = "Transformation",
PLUGIN_CATEGORY_AUTHENTICATION = "Authentication",
PLUGIN_CATEGORY_SECURITY = "Security",
PLUGIN_CATEGORY_TRAFFIC = "Traffic",
PLUGIN_CATEGORY_OBSERVABILITY = "Observability",
PLUGIN_CATEGORY_SERVERLESS = "Serverless",
PLUGIN_CATEGORY_OTHER_PROTOCOLS = "Other protocols",
}
7 changes: 7 additions & 0 deletions apisix/plugins/api-breaker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
-- limitations under the License.
--

local require = require
local core = require("apisix.core")
local constants = require("apisix.constants")
local plugin_name = "api-breaker"
local ngx = ngx
local math = math
Expand All @@ -32,6 +34,11 @@ end
local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_TRAFFIC
},
break_response_code = {
type = "integer",
minimum = 200,
Expand Down
8 changes: 7 additions & 1 deletion apisix/plugins/authz-casbin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

local require = require
local casbin = require("casbin")
local core = require("apisix.core")
local plugin = require("apisix.plugin")
local constants = require("apisix.constants")

local plugin_name = "authz-casbin"

local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_AUTHENTICATION
},
model_path = { type = "string" },
policy_path = { type = "string" },
model = { type = "string" },
Expand Down
7 changes: 7 additions & 0 deletions apisix/plugins/authz-casdoor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
local require = require
local core = require("apisix.core")
local http = require("resty.http")
local session = require("resty.session")
local constants = require("apisix.constants")
local ngx = ngx
local rand = math.random
local tostring = tostring
Expand All @@ -26,6 +28,11 @@ local plugin_name = "authz-casdoor"
local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_AUTHENTICATION
},
-- Note: endpoint_addr and callback_url should not end with '/'
endpoint_addr = {type = "string", pattern = "^[^%?]+[^/]$"},
client_id = {type = "string"},
Expand Down
7 changes: 7 additions & 0 deletions apisix/plugins/authz-keycloak.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
local require = require
local core = require("apisix.core")
local http = require "resty.http"
local constants = require("apisix.constants")
local sub_str = string.sub
local type = type
local ngx = ngx
Expand All @@ -28,6 +30,11 @@ local pairs = pairs
local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_AUTHENTICATION
},
discovery = {type = "string", minLength = 1, maxLength = 4096},
token_endpoint = {type = "string", minLength = 1, maxLength = 4096},
resource_registration_endpoint = {type = "string", minLength = 1, maxLength = 4096},
Expand Down
9 changes: 9 additions & 0 deletions apisix/plugins/basic-auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
local require = require
local core = require("apisix.core")
local ngx = ngx
local ngx_re = require("ngx.re")
local consumer = require("apisix.consumer")
local constants = require("apisix.constants")


local lrucache = core.lrucache.new({
ttl = 300, count = 512
})
Expand All @@ -26,6 +30,11 @@ local schema = {
type = "object",
title = "work with route or service object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_AUTHENTICATION
},
hide_credentials = {
type = "boolean",
default = false,
Expand Down
9 changes: 9 additions & 0 deletions apisix/plugins/batch-requests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
local require = require
local core = require("apisix.core")
local http = require("resty.http")
local plugin = require("apisix.plugin")
local constants = require("apisix.constants")
local ngx = ngx
local ipairs = ipairs
local pairs = pairs
Expand All @@ -41,6 +43,13 @@ local attr_schema = {

local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_GENERAL
},
}
}

local default_max_body_size = 1024 * 1024 -- 1MiB
Expand Down
7 changes: 7 additions & 0 deletions apisix/plugins/body-transformer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
local require = require
local core = require("apisix.core")
local xml2lua = require("xml2lua")
local xmlhandler = require("xmlhandler.tree")
local template = require("resty.template")
local constants = require("apisix.constants")
local ngx = ngx
local decode_base64 = ngx.decode_base64
local req_set_body_data = ngx.req.set_body_data
Expand All @@ -44,6 +46,11 @@ local transform_schema = {
local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_TRANSFORMATION
},
request = transform_schema,
response = transform_schema,
},
Expand Down
7 changes: 7 additions & 0 deletions apisix/plugins/cas-auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
---- See the License for the specific language governing permissions and
---- limitations under the License.
----
local require = require
local core = require("apisix.core")
local http = require("resty.http")
local constants = require("apisix.constants")
local ngx = ngx
local ngx_re_match = ngx.re.match

Expand All @@ -32,6 +34,11 @@ local plugin_name = "cas-auth"
local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_AUTHENTICATION
},
idp_uri = {type = "string"},
cas_callback_uri = {type = "string"},
logout_uri = {type = "string"},
Expand Down
7 changes: 7 additions & 0 deletions apisix/plugins/chaitin-waf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

local require = require
local core = require("apisix.core")
local rr_balancer = require("apisix.balancer.roundrobin")
local plugin = require("apisix.plugin")
local t1k = require "resty.t1k"
local expr = require("resty.expr.v1")
local constants = require("apisix.constants")

local ngx = ngx
local ngx_now = ngx.now
Expand Down Expand Up @@ -50,6 +52,11 @@ local plugin_schema = {
properties = {
-- TODO: we should add a configuration "mode" here
-- It can be one of off, block and monitor
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_SECURITY
},
match = match_schema,
append_waf_resp_header = {
type = "boolean",
Expand Down
7 changes: 7 additions & 0 deletions apisix/plugins/clickhouse-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
-- limitations under the License.
--

local require = require
local bp_manager_mod = require("apisix.utils.batch-processor-manager")
local log_util = require("apisix.utils.log-util")
local core = require("apisix.core")
local http = require("resty.http")
local url = require("net.url")
local constants = require("apisix.constants")
local math_random = math.random

local tostring = tostring
Expand All @@ -30,6 +32,11 @@ local batch_processor_manager = bp_manager_mod.new(plugin_name)
local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_OBSERVABILITY
},
-- deprecated, use "endpoint_addrs" instead
endpoint_addr = core.schema.uri_def,
endpoint_addrs = {items = core.schema.uri_def, type = "array", minItems = 1},
Expand Down
7 changes: 7 additions & 0 deletions apisix/plugins/client-control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@
-- limitations under the License.
--
local require = require
local require = require
local core = require("apisix.core")
local constants = require("apisix.constants")
local ok, apisix_ngx_client = pcall(require, "resty.apisix.client")
local tonumber = tonumber


local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_TRAFFIC
},
max_body_size = {
type = "integer",
minimum = 0,
Expand Down
9 changes: 9 additions & 0 deletions apisix/plugins/consumer-restriction.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
local require = require
local ipairs = ipairs
local core = require("apisix.core")
local constants = require("apisix.constants")
local ngx = ngx


local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_SECURITY
},
type = {
type = "string",
enum = {"consumer_name", "service_id", "route_id", "consumer_group_id"},
Expand Down
7 changes: 7 additions & 0 deletions apisix/plugins/cors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
local require = require
local core = require("apisix.core")
local plugin = require("apisix.plugin")
local constants = require("apisix.constants")
local ngx = ngx
local plugin_name = "cors"
local str_find = core.string.find
Expand Down Expand Up @@ -48,6 +50,11 @@ local metadata_schema = {
local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_SECURITY
},
allow_origins = {
description =
"you can use '*' to allow all origins when no credentials," ..
Expand Down
8 changes: 8 additions & 0 deletions apisix/plugins/csrf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

local require = require
local core = require("apisix.core")
local resty_sha256 = require("resty.sha256")
local str = require("resty.string")
local constants = require("apisix.constants")
local ngx = ngx
local ngx_encode_base64 = ngx.encode_base64
local ngx_decode_base64 = ngx.decode_base64
Expand All @@ -29,6 +32,11 @@ local SAFE_METHODS = {"GET", "HEAD", "OPTIONS"}
local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_SECURITY
},
key = {
description = "use to generate csrf token",
type = "string",
Expand Down
8 changes: 7 additions & 1 deletion apisix/plugins/datadog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

local require = require
local core = require("apisix.core")
local plugin = require("apisix.plugin")
local constants = require("apisix.constants")
local bp_manager_mod = require("apisix.utils.batch-processor-manager")
local fetch_log = require("apisix.utils.log-util").get_full_log
local service_fetch = require("apisix.http.service").get
Expand All @@ -37,6 +38,11 @@ local batch_processor_manager = bp_manager_mod.new(plugin_name)
local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_OBSERVABILITY
},
prefer_name = {type = "boolean", default = true}
}
}
Expand Down
7 changes: 7 additions & 0 deletions apisix/plugins/degraphql.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
local require = require
local core = require("apisix.core")
local gq_parse = require("graphql").parse
local constants = require("apisix.constants")
local req_set_body_data = ngx.req.set_body_data
local ipairs = ipairs
local pcall = pcall
Expand All @@ -25,6 +27,11 @@ local type = type
local schema = {
type = "object",
properties = {
category = {
type = "string",
description = "This field is used for plugin classification",
default = constants.PLUGIN_CATEGORY_TRANSFORMATION
},
query = {
type = "string",
minLength = 1,
Expand Down
Loading

0 comments on commit 193b798

Please sign in to comment.