修复会话存档API使用错误secret导致权限异常的问题 #3873
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题
会话存档相关API(
getPermitUserList、getGroupChat、checkSingleAgree)使用应用secret获取的access token,而企业微信要求这些API必须使用会话存档专用secret获取独立的access token,导致返回权限错误。变更
配置层
WxCpConfigStorage: 新增会话存档access token管理方法(获取、更新、过期检查、锁)WxCpDefaultConfigImpl: 实现会话存档access token存储和生命周期管理WxCpRedisConfigImpl: 添加存根实现服务层
WxCpService: 新增getMsgAuditAccessToken(boolean forceRefresh)方法WxCpServiceImpl、WxCpServiceApacheHttpClientImpl、WxCpServiceHttpComponentsImpl、WxCpServiceOkHttpImpl、WxCpServiceJoddHttpImpl):实现使用会话存档secret获取专用access token,采用双重检查锁定避免并发重复刷新业务层
WxCpMsgAuditServiceImpl: 修改getPermitUserList、getGroupChat、checkSingleAgree方法,使用会话存档专用access token使用示例
技术细节
各HTTP客户端实现采用相应的线程安全机制:
HttpGet+ApacheBasicResponseHandlertry-with-resources确保Response正确关闭HttpRequest+open().bodyText()所有实现均在secret未配置时抛出明确的
WxErrorException("会话存档secret未配置")。Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
developer.work.weixin.qq.com/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.