hwh
2024-06-21 c00475aec109bfbde3781bd2c4899b8d1a040a07
处理非空参数验签
1个文件已修改
28 ■■■■■ 已修改文件
Wms/Utility/Filter/ApiSignatureVerificationAttribute.cs 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/Utility/Filter/ApiSignatureVerificationAttribute.cs
@@ -59,20 +59,24 @@
            // 反序列化 JSON 参数为 JObject
            JObject jObject = null;
            try
            Dictionary<string, string> filteredProperties = new Dictionary<string, string>();
            if (jsonParams != null)
            {
                jObject = JObject.Parse(jsonParams);
                try
                {
                    jObject = JObject.Parse(jsonParams);
                    // 过滤掉数组类型的属性
                    filteredProperties = jObject.Properties()
                        .Where(p => p.Value.Type != JTokenType.Array)
                        .ToDictionary(p => p.Name, p => p.Value.ToString());
                }
                catch (JsonReaderException)
                {
                    // JSON 格式错误,返回未经授权
                    context.Result = new UnauthorizedResult();
                    return;
                }
            }
            catch (JsonReaderException)
            {
                // JSON 格式错误,返回未经授权
                context.Result = new UnauthorizedResult();
                return;
            }
            // 过滤掉数组类型的属性
            var filteredProperties = jObject.Properties()
                .Where(p => p.Value.Type != JTokenType.Array)
                .ToDictionary(p => p.Name, p => p.Value.ToString());
            filteredProperties.Add("timestamp", timestamp);
            filteredProperties.Add("appKey", appKey);