网站怎么增加代码市场调研报告模板
web/
2025/10/6 4:04:15/
文章来源:
网站怎么增加代码,市场调研报告模板,建设银行手机银行网站用户名是什么原因,蓝韵官方网站一、验签的背景
在网络发展快速的过程中#xff0c;总是会忽略接口数据安全问题#xff0c;进行验签则能够在一定程度上能够防刷#xff0c;数据篡改。
二、什么是加签验签
加签验签#xff0c;
发送消息方#xff0c;对消息加签名#xff1b;
接受消息方#xff0…一、验签的背景
在网络发展快速的过程中总是会忽略接口数据安全问题进行验签则能够在一定程度上能够防刷数据篡改。
二、什么是加签验签
加签验签
发送消息方对消息加签名
接受消息方验证签名是否正确。
发送消息方
1、根据消息内容形成摘要
2、根据摘要形成签名字段
3、发送消息
接受消息方
1、接受消息
2、根据消息内容形成摘要
3、根据摘要去验证签名是否正确
三、实物电商验签规则
3.1 请求头 Header 增加参数
3.1.1 Expires时间戳 单位 毫秒
3.1.2 X-Request-Id(前端生成的随机数数字加字母的组合)
3.1.3 Signature摘要 生成
signstr: 请求参数ASCALL表排序再按照该顺序拼接成一个字符串X-Request-Id请求idExpires时间戳
公式Signature signstr requestId time 注意
时间校准空值的key 不参与ASCALL表排序 参考 可以参考下面的值来测试生成的签名是否正确
Accept: application/json, text/plain, */*Accept-Encoding: gzip, deflateAccept-Language: en_USAuthorization: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiIxNTk5NjM2NTUyOEAxNjMuY29tIiwic2NvcGUiOlsiYWxsIl0sImlkIjozNTU5LCJleHAiOjE2Njg1ODkxMjUsImF1dGhvcml0aWVzIjpbIuWJjeWPsOS8muWRmCJdLCJqdGkiOiIyZDAxMWVhOS02N2RjLTRmZmQtOTAwMS1jYTMwNTU1MzM0NzkiLCJjbGllbnRfaWQiOiJmcm9udC1hcHAifQ.AkKh_rTiIn1tckM-hvbM5o9lKEESd9TFz19W8xKDVcVisgwZ6tUTYcROB3JUdijGq-_7VnEnFjmjY3qXYeOHngo_ctDgw6KQqkDghSHGUDohI2SLXiTuHDZtp6H_f1wnTXYnHWqox7hwiNIWYbckkh4sRw6jkNDQAf6KfxccJ0YConnection: keep-aliveCookie: _gaGA1.1.500562097.1650948294; _ga_TZED0ZY3LFGS1.1.1667983869.442.1.1667984325.0.0.0Expires: 1667984325369Host: h5.newsitunemall.comReferer: http://h5.newsitunemall.com/mineSignature: 1c356d047bcb10de8c1700ab3f3f25ecSource: h5User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36version: 1.0.82X-Request-Id: acc9d18b85159844ea89e758747ecfa3
3.2 时间校准逻辑
3.2.1 请求被动触发 具体接口
接口home/timestamp
方式GET
返回
{code: 200,message: operation success,data: 1668653868836,timestamp: 1668653868836,success: true
}
3.2.2 首页 主动触发
首页被用户点击的时候主动请求一下接口校准时间戳 3.2.3 前端验签规则 3.2.4 后端解签代码
public void checkSign(String sign, MapString, String requestParam,String timestamp, String requestId, URI uri){if (StrUtil.isBlank(sign) || StrUtil.isBlank(timestamp) || StrUtil.isBlank(requestId)) {LOGGER.error(illegal request sign:{} timestamp:{} requestId:{},sign,timestamp,requestId);throw new ApiException(illegal request,param is null!);}long time;try {time Long.parseLong(timestamp);} catch (Exception e) {LOGGER.error(illegal request timestamp不合法,timestamp: timestamp);throw new ApiException(timestamp illegal);}//验证时间戳是否过期long currentTime System.currentTimeMillis();if (time currentTime timeOver || time currentTime - timeOver) {LOGGER.error(illegal request timestamp expires now:{} timestamp:{},currentTime,time);throw new ApiException(please refresh);}if(redisTemplate.hasKey(requestId)){LOGGER.error(illegal request requestId exist:{},requestId);throw new ApiException(illegal request,requestId exist:requestId);}else{redisTemplate.opsForValue().set(requestId, requestId,timeOver, TimeUnit.MILLISECONDS);}String paramAscII MapUtil.sortJoin(requestParam, , , true, requestId, timestamp);String md5 new Digester(DigestAlgorithm.MD5).digestHex(paramAscII);if (!md5.equals(sign)) {LOGGER.error(illegal request,check sign fail! paramAscII:{} sourceSign:{} sysSign:{},paramAscII,sign,md5);throw new ApiException(illegal request,check sign fail);}}
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/87729.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!