问题描述 (Problem Description)
根据微信小程序官方文档,获取手机号接口 POST https://api.weixin.qq.com/wxa/business/getuserphonenumber 的 Request Payload 参数除了必填的 code 之外,还支持选填参数 openid:
openid(选填):用户 openid,填入后微信服务端会校验 openid 和 code 的绑定关系,并在不匹配时直接报错返回。
但在目前 weixin-java-miniapp 的 WxMaUserService 中,仅提供了单参数方法:
WxMaPhoneNumberInfo getPhoneNumber(String code)
由于缺少 openid 参数的传递,当开发者直接使用该方法时,无法触发微信服务端的 openid <-> code 匹配校验,在部分业务场景下可能存在越权安全隐患。
官方文档参考 (References)
建议与改进方案 (Proposed Solution)
建议在 WxMaUserService 接口及其实现类 WxMaUserServiceImpl 中增加重载方法,允许传入 openid:
- 接口定义:
/**
* 获取手机号信息
*
* @param code 手机号获取凭证
* @param openid 用户 openid(选填,填入后会校验 openid 和 code 的绑定关系)
* @return 手机号信息
*/
WxMaPhoneNumberInfo getPhoneNumber(String code, String openid) throws WxErrorException;
问题描述 (Problem Description)
根据微信小程序官方文档,获取手机号接口
POST https://api.weixin.qq.com/wxa/business/getuserphonenumber的 Request Payload 参数除了必填的code之外,还支持选填参数openid:openid(选填):用户 openid,填入后微信服务端会校验 openid 和 code 的绑定关系,并在不匹配时直接报错返回。但在目前
weixin-java-miniapp的WxMaUserService中,仅提供了单参数方法:WxMaPhoneNumberInfo getPhoneNumber(String code)由于缺少
openid参数的传递,当开发者直接使用该方法时,无法触发微信服务端的openid <-> code匹配校验,在部分业务场景下可能存在越权安全隐患。官方文档参考 (References)
建议与改进方案 (Proposed Solution)
建议在
WxMaUserService接口及其实现类WxMaUserServiceImpl中增加重载方法,允许传入openid: