@@ -19,46 +19,8 @@ local plugins = require("apisix.admin.plugins")
19
19
local resource = require (" apisix.admin.resource" )
20
20
local plugin = require (" apisix.plugin" )
21
21
local pairs = pairs
22
- local consumer = require (" apisix.consumer" )
23
22
local utils = require (" apisix.admin.utils" )
24
23
25
-
26
- local function check_duplicate_key (username , plugins_conf )
27
- if not plugins_conf then
28
- return true
29
- end
30
-
31
- for plugin_name , plugin_conf in pairs (plugins_conf ) do
32
- local plugin_obj = plugin .get (plugin_name )
33
- if not plugin_obj then
34
- return nil , " unknown plugin " .. plugin_name
35
- end
36
-
37
- if plugin_obj .type ~= " auth" then
38
- goto continue
39
- end
40
-
41
- local key_field = utils .plugin_key_map [plugin_name ]
42
- if not key_field then
43
- goto continue
44
- end
45
-
46
- local key_value = plugin_conf [key_field ]
47
- if not key_value then
48
- goto continue
49
- end
50
-
51
- local consumer = consumer .find_consumer (plugin_name , key_field , key_value )
52
- if consumer and consumer .username ~= username then
53
- return nil , " duplicate key found with consumer: " .. consumer .username
54
- end
55
-
56
- :: continue::
57
- end
58
-
59
- return true
60
- end
61
-
62
24
local function check_conf (username , conf , need_username , schema )
63
25
local ok , err = core .schema .check (schema , conf )
64
26
if not ok then
@@ -77,7 +39,7 @@ local function check_conf(username, conf, need_username, schema)
77
39
if not ok then
78
40
return nil , {error_msg = " invalid plugins configuration: " .. err }
79
41
end
80
- local ok , err = check_duplicate_key (conf .username , conf_plugins_copy )
42
+ local ok , err = utils . check_duplicate_key (conf_plugins_copy , conf .username )
81
43
if not ok then
82
44
return nil , {error_msg = err }
83
45
end
0 commit comments