Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions apisix/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,13 @@ end
-- - Arbitrary depth dotted paths (e.g., "a.b.c.d")
-- - Array traversal at intermediate nodes (iterate each element)
-- - Leaf type dispatch: string, array of strings, map of strings
local decrypt_hint = ". This can happen after upgrading if the field was recently "
.. "added to encrypt_fields; if the value was encrypted, verify the data_encryption "
.. "keyring. Re-save the configuration via the Admin API to resolve."

local function process_encrypt_field(conf, key_path, operation, plugin_name, op_name)
local log_func = op_name == "decrypt" and core.log.info or core.log.warn
local hint = op_name == "decrypt" and decrypt_hint or ""
local dot_pos = core.string.find(key_path, ".")

if not dot_pos then
Expand All @@ -1006,8 +1012,8 @@ local function process_encrypt_field(conf, key_path, operation, plugin_name, op_
if type(val) == "string" then
local result, err = operation(val, "data_encrypt")
if not result then
core.log.warn("failed to ", op_name, " the conf of plugin [",
plugin_name, "] key [", key_path, "], err: ", err)
log_func("failed to ", op_name, " the conf of plugin [",
plugin_name, "] key [", key_path, "], err: ", err, hint)
else
conf[key_path] = result
end
Expand All @@ -1019,9 +1025,9 @@ local function process_encrypt_field(conf, key_path, operation, plugin_name, op_
if type(item) == "string" then
local result, err = operation(item, "data_encrypt")
if not result then
core.log.warn("failed to ", op_name, " the conf of plugin [",
plugin_name, "] key [", key_path,
"] index [", i, "], err: ", err)
log_func("failed to ", op_name, " the conf of plugin [",
plugin_name, "] key [", key_path,
"] index [", i, "], err: ", err, hint)
else
val[i] = result
end
Expand All @@ -1033,9 +1039,9 @@ local function process_encrypt_field(conf, key_path, operation, plugin_name, op_
if type(v) == "string" then
local result, err = operation(v, "data_encrypt")
if not result then
core.log.warn("failed to ", op_name, " the conf of plugin [",
plugin_name, "] key [", key_path,
".", k, "], err: ", err)
log_func("failed to ", op_name, " the conf of plugin [",
plugin_name, "] key [", key_path,
".", k, "], err: ", err, hint)
else
val[k] = result
end
Expand Down
Loading