Baoyuantop commented on code in PR #12040:
URL: https://github.com/apache/apisix/pull/12040#discussion_r1998110124


##########
apisix/admin/consumers.lua:
##########
@@ -32,7 +34,50 @@ local function check_conf(username, conf, need_username, 
schema)
     if conf.plugins then
         ok, err = plugins.check_schema(conf.plugins, core.schema.TYPE_CONSUMER)
         if not ok then
-            return nil, {error_msg = "invalid plugins configuration: " .. err}
+            return nil, {
+                error_msg = "invalid plugins configuration: " .. err
+            }
+        end
+
+        -- check duplicate key
+        for plugin_name, plugin_conf in pairs(conf.plugins or {}) do
+            local plugin_obj = plugin.get(plugin_name)
+            if not plugin_obj then
+                return nil, {error_msg = "unknown plugin " .. plugin_name}
+            end
+
+            if plugin_obj.type == "auth" then
+                local decrypted_conf = core.table.deepcopy(plugin_conf)
+                plugin.decrypt_conf(plugin_name, decrypted_conf, 
core.schema.TYPE_CONSUMER)
+
+                local plugin_key_map = {
+                    ["key-auth"] = "key",
+                    ["basic-auth"] = "username",
+                    ["jwt-auth"] = "key",
+                    ["hmac-auth"] = "key_id"
+                }
+
+                local key_field = plugin_key_map[plugin_name]
+
+                if key_field then
+                    local key_value = decrypted_conf[key_field]
+
+                    if key_value then
+                        local consumer, _, err = consumer
+                            .find_consumer(plugin_name, key_field, key_value)
+                        if err then
+                            core.log.warn("failed to find consumer: ", err)

Review Comment:
   When fixing the failure test, I found that when calling the 
`find_consumer()` method, its internal call will do a secret find and replace, 
and when given a non-existing secret, there will be an internal error log, 
where the err data is captured and printed.
   It is also possible to remove this log.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to