-
Notifications
You must be signed in to change notification settings - Fork 0
<fix>[identity]: ValidateSession clear SSOToken #4159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,10 @@ public class Session implements Component { | |
| private DatabaseFacade dbf; | ||
| @Autowired | ||
| private EventFacade evtf; | ||
| @Autowired | ||
| private PluginRegistry pluginRgty; | ||
|
|
||
| private static List<LogoutExtensionPoint> logoutExtensionPoints; | ||
|
|
||
| private Future<Void> expiredSessionCollector; | ||
| private static Interner<String> sessionLock = Interners.newWeakInterner(); | ||
|
|
@@ -221,6 +225,11 @@ protected ErrorCode scripts() { | |
| } | ||
|
|
||
| logout(s.getUuid()); | ||
|
|
||
| for (LogoutExtensionPoint ext : logoutExtensionPoints) { | ||
| ext.beforeLogout(s); | ||
| } | ||
|
|
||
| return err(IdentityErrors.INVALID_SESSION, "Session expired"); | ||
| } | ||
|
|
||
|
|
@@ -266,6 +275,7 @@ public boolean start() { | |
| setupGlobalConfig(); | ||
| startCleanUpStaleSessionTask(); | ||
| setupCanonicalEvents(); | ||
| logoutExtensionPoints = pluginRgty.getExtensionList(LogoutExtensionPoint.class); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 静态
此外,本文件中 ♻️ 方案一(推荐):按需获取,移除静态缓存- private static List<LogoutExtensionPoint> logoutExtensionPoints;- for (LogoutExtensionPoint ext : logoutExtensionPoints) {
- ext.beforeLogout(s);
- }
+ getComponentLoader().getComponent(PluginRegistry.class)
+ .getExtensionList(LogoutExtensionPoint.class)
+ .forEach(ext -> ext.beforeLogout(s));- logoutExtensionPoints = pluginRgty.getExtensionList(LogoutExtensionPoint.class);
return true;方案二(保留缓存):在遍历前对 🤖 Prompt for AI Agents |
||
| return true; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 1799
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 105
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 16874
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 6641
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 817
修正 LogoutExtensionPoint 的调用时序并避免 logoutExtensionPoints 初始化竞态
Session的过期清理分支里先执行Session.logout(s.getUuid())(会从缓存与 DB 中删除会话),随后才遍历logoutExtensionPoints调用ext.beforeLogout(s);与AccountManagerImpl的APILogOutMsg流程(先beforeLogout,再logOutSession->Session.logout)不一致,beforeLogout语义与实际顺序相反。logoutExtensionPoints为static,start()中在startCleanUpStaleSessionTask()之后才赋值,若 periodic task 在赋值前触发,可能出现null导致 NPE。🔧 建议调整调用顺序
🤖 Prompt for AI Agents