From 574197f2f9800f2d3ab31677bf41ae12c77f425c Mon Sep 17 00:00:00 2001 From: Madhawa Gunasekara Date: Sun, 12 Nov 2023 19:39:55 +0100 Subject: [PATCH] fix code checks --- apisix/plugins/multi-auth.lua | 2 +- docs/en/latest/config.json | 3 ++- docs/en/latest/getting-started/key-authentication.md | 1 + docs/zh/latest/getting-started/key-authentication.md | 1 + t/admin/plugins.t | 2 +- t/plugin/multi-auth.t | 8 ++++---- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/apisix/plugins/multi-auth.lua b/apisix/plugins/multi-auth.lua index c7322942d62c0..82e6e594ac130 100644 --- a/apisix/plugins/multi-auth.lua +++ b/apisix/plugins/multi-auth.lua @@ -69,7 +69,7 @@ function _M.rewrite(conf, ctx) for k, auth_plugin in pairs(auth_plugins) do for key, value in pairs(auth_plugin) do local auth = require("apisix.plugins." .. key) - local auth_code, b = auth.rewrite(value, ctx) + local auth_code = auth.rewrite(value, ctx) status_code = auth_code if auth_code == nil then core.log.debug("Authentication is successful" .. key .. " plugin") diff --git a/docs/en/latest/config.json b/docs/en/latest/config.json index e1c8391f275b8..05f63bd63fed2 100644 --- a/docs/en/latest/config.json +++ b/docs/en/latest/config.json @@ -111,7 +111,8 @@ "plugins/authz-casbin", "plugins/ldap-auth", "plugins/opa", - "plugins/forward-auth" + "plugins/forward-auth", + "plugins/multi-auth" ] }, { diff --git a/docs/en/latest/getting-started/key-authentication.md b/docs/en/latest/getting-started/key-authentication.md index 725bcd3527b9c..f6e8a8383f0f7 100644 --- a/docs/en/latest/getting-started/key-authentication.md +++ b/docs/en/latest/getting-started/key-authentication.md @@ -28,6 +28,7 @@ APISIX has a flexible plugin extension system and a number of existing plugins f - [LDAP](https://apisix.apache.org/docs/apisix/plugins/ldap-auth/) - [Open Policy Agent (OPA)](https://apisix.apache.org/docs/apisix/plugins/opa/) - [Forward Authentication](https://apisix.apache.org/docs/apisix/plugins/forward-auth/) +- [Multiple Authentications](https://apisix.apache.org/docs/apisix/plugins/multi-auth/) In this tutorial, you will create a _consumer_ with _key authentication_, and learn how to enable and disable key authentication. diff --git a/docs/zh/latest/getting-started/key-authentication.md b/docs/zh/latest/getting-started/key-authentication.md index ddcce9029db02..022f020ae9090 100644 --- a/docs/zh/latest/getting-started/key-authentication.md +++ b/docs/zh/latest/getting-started/key-authentication.md @@ -28,6 +28,7 @@ APISIX 拥有灵活的插件扩展系统,目前有很多可用于用户身份 - [LDAP](https://apisix.apache.org/zh/docs/apisix/plugins/ldap-auth/) - [Open Policy Agent (OPA)](https://apisix.apache.org/zh/docs/apisix/plugins/opa/) - [Forward Authentication](https://apisix.apache.org/zh/docs/apisix/plugins/forward-auth/) +- [Multiple Authentications](https://apisix.apache.org/docs/apisix/plugins/multi-auth/) 本教程中,你将创建一个带有 _密钥验证_ 插件的 _消费者_,并学习如何启用和停用身份验证插件。 diff --git a/t/admin/plugins.t b/t/admin/plugins.t index 68206bf3d76d4..e7b736fd959c1 100644 --- a/t/admin/plugins.t +++ b/t/admin/plugins.t @@ -312,7 +312,7 @@ qr/\{"metadata_schema":\{"properties":\{"ikey":\{"minimum":0,"type":"number"\}," } } --- response_body eval -qr/\[\{"name":"wolf-rbac","priority":2555\},\{"name":"ldap-auth","priority":2540\},\{"name":"hmac-auth","priority":2530\},\{"name":"basic-auth","priority":2520\},\{"name":"jwt-auth","priority":2510\},\{"name":"key-auth","priority":2500\}\]/ +qr/\[\{"name":"multi-auth","priority":2600\},\{"name":"wolf-rbac","priority":2555\},\{"name":"ldap-auth","priority":2540\},\{"name":"hmac-auth","priority":2530\},\{"name":"basic-auth","priority":2520\},\{"name":"jwt-auth","priority":2510\},\{"name":"key-auth","priority":2500\}\]/ diff --git a/t/plugin/multi-auth.t b/t/plugin/multi-auth.t index fc4e492aa5425..72360f5d1bc1e 100644 --- a/t/plugin/multi-auth.t +++ b/t/plugin/multi-auth.t @@ -154,7 +154,7 @@ GET /hello Authorization: Basic YmFyOmJhcgo= --- error_code: 401 --- response_body -{"message":"Authorization Failed."} +{"message":"Authorization Failed"} @@ -165,7 +165,7 @@ GET /hello apikey: auth-two --- error_code: 401 --- response_body -{"message":"Authorization Failed."} +{"message":"Authorization Failed"} @@ -200,7 +200,7 @@ apikey: auth-two GET /t --- error_code: 400 --- response_body -{"error_msg":"invalid plugins configuration: failed to check the configuration of plugin multi-auth err: property \"auth_plugins\" is required"} +{"error_msg":"failed to check the configuration of plugin multi-auth err: property \"auth_plugins\" is required"} @@ -241,4 +241,4 @@ GET /t GET /t --- error_code: 400 --- response_body -{"error_msg":"invalid plugins configuration: failed to check the configuration of plugin multi-auth err: property \"auth_plugins\" validation failed: expect array to have at least 2 items"} +{"error_msg":"failed to check the configuration of plugin multi-auth err: property \"auth_plugins\" validation failed: expect array to have at least 2 items"}