Skip to content

修复小程序登录接口的 token 依赖并支持无 token 请求 - #4140

Open
binarywang wants to merge 1 commit into
developfrom
fix/4138-miniapp-without-token
Open

binarywang wants to merge 1 commit into
developfrom
fix/4138-miniapp-without-token

Conversation

@binarywang

Copy link
Copy Markdown
Owner

小程序 jscode2session 无需 access_token,但现有登录封装会先获取 token 并拼接到请求中,导致登录依赖不必要的 token 获取过程。本次让 jsCode2SessionInfo()(及委托它的 getSessionInfo())改走无 token 请求路径。

新增 getWithoutToken()、postWithoutToken() 和 executeWithoutToken()。内置 HTTP 实现保留 API 主机配置、系统繁忙重试和敏感信息日志保护;无 token 请求不会刷新或使缓存 token 过期。接口通过 Java 8 默认方法扩展,普通请求的 token 处理保持原有行为。

验证:15 项相关测试通过,覆盖 Apache HttpClient、HttpComponents、OkHttp、Jodd 的登录及无 token GET/POST,以及重试上限、异常、账号切换和普通 token 刷新。git diff --check 通过。

mvn -pl weixin-java-miniapp -am -Dmaven.test.skip=false -Dtest=WxMaCode2SessionSecurityTest,WxMaSignaturePayloadTest,WxMaUserServiceImplCheckSessionKeyTest,WxMaUserServiceImplPhoneNumberTest -Dsurefire.failIfNoSpecifiedTests=false test

未执行需要微信凭据的全量集成测试。

Fixes #4138

Copilot AI balanced review requested due to automatic review settings October 14, 2026 10:03
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T10:06:40.901641Z 3a41369 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@augmentcode

augmentcode Bot commented Oct 14, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

概要:修复小程序登录对 access_token 的不必要依赖,关联 #4138。

  • `jsCode2SessionInfo()` 改为无 token GET 请求。
  • 委托该方法的 `getSessionInfo()` 同步受益。
  • 新增 `getWithoutToken()`、`postWithoutToken()` 和 `executeWithoutToken()`。
  • 通过 Java 8 默认方法扩展服务接口,为自定义实现提供直接执行路径。
  • 内置实现沿用 API 主机替换与系统繁忙重试机制。
  • 无 token 请求不获取、追加、刷新或使缓存 token 过期。
  • 普通请求仍保留原有 token 刷新逻辑,无 token POST 不自动启用接口签名。
  • 扩展四种 HTTP 客户端、重试上限、异常保护及账号切换等回归测试。
审查结论:静态审查未发现可确认的新增缺陷;未运行测试,PR 描述报告相关 15 项测试通过。

🤖 Was this summary useful? React with 👍 or 👎

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

通用无 token 请求会被错误记录为 code2Session 请求,需修正诊断日志语义。

1 open finding
What changed in this PR

修复小程序登录接口对 access_token 的非必要依赖,并新增通用无 token 请求能力。

Changes:

  • jscode2session 改用无 token 请求路径。
  • 新增无 token GET、POST 和自定义执行接口。
  • 补充四种 HTTP 客户端及重试、账号切换测试。
File Description
WxMaService.java 定义无 token 请求公共 API。
BaseWxMaServiceImpl.java 实现无 token 执行、主机替换与重试。
WxMaCode2SessionSecurityTest.java 验证登录和无 token 请求行为。

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +410 to +411
return this.executeInternal(executor, uri, dataForLog, false,
!withToken || JSCODE_TO_SESSION_URL.equals(uri), withToken);

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

支持不携带access_token请求特定接口

2 participants