Repository navigation
Conversation
Emryswu
force-pushed
the
feat/issue-987-open-safe-token
branch
from
October 14, 2026 04:07
7b0a139 to
adc3287
Compare
|
已看到提交,大概什么时候能够合并发版? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #987
改了什么
按 issue 里的讨论,二级认证的完整流程现在都可以直接传 token 操作,适合 RPC 调用这类只能拿到 token、没有 HTTP 请求上下文的场景。
StpLogic和StpUtil都加了:openSafe(tokenValue, service, safeTime):为指定 token 开启二级认证checkSafe(tokenValue, service):校验指定 token 是否已通过二级认证getSafeTime(tokenValue, service):获取指定 token 的二级认证剩余时间closeSafe(tokenValue, service):结束指定 token 的二级认证行为约定:
openSafe/checkSafe的 token 校验与现有isSafe(tokenValue, service)一致(空值、登录映射、异常标记),token 无效时抛NotLoginException;checkSafe在未认证时抛NotSafeException。校验逻辑抽到了protected checkSafeTokenValid(...)里共用。getSafeTime/closeSafe与当前会话版本保持一致:空 token 分别返回 -2 / 不做任何操作;closeSafe照常发布doCloseSafe事件。getSafeTime(service)、closeSafe(service)改为取当前 token 后调用新方法,行为不变;openSafe(service, safeTime)、checkSafe(service)也保持原样。测试
在
StpLogicSafeSwitchTest和StpUtilTest里补了用例,覆盖:无请求上下文下的完整流程(开启 → 校验 → 剩余时间 → 关闭)、token / 业务隔离、有效期、无效及异常标记 token、事件参数(开启与关闭),以及旧入口的兼容性。