fix(auth): stabilize oauth session after callback#245
Open
Conversation
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.
概述
修复 Cloudflare Tunnel 场景下 GitHub OAuth 授权成功后会话丢失,导致回到登录页的问题。
变更内容
后端实现
attachToAuthenticatedSession(..., true)改为attachToAuthenticatedSession(...),避免与 Spring Security 默认会话固定防护叠加,导致代理场景下 Cookie/Session 不稳定。server/skillhub-auth/src/main/java/com/iflytek/skillhub/auth/oauth/OAuth2LoginSuccessHandler.java前端实现
测试覆盖
OAuth2LoginHandlersTest,校验 OAuth 成功后 Session 仍写入platformPrincipal与SecurityContext,并验证不依赖额外 session rotate。server/skillhub-auth/src/test/java/com/iflytek/skillhub/auth/oauth/OAuth2LoginHandlersTest.javacd server && ./mvnw -pl skillhub-auth -am test -Dtest=OAuth2LoginHandlersTest,OAuthLoginFlowServiceTest -Dsurefire.failIfNoSpecifiedTests=false质量门禁
make typecheck-web通过(0 errors)make lint-web通过(0 errors, 0 warnings)make test-frontend通过make test-backend-app通过web/e2e)关键路径通过(本次无前端改动,不适用)make generate-api已执行且schema.d.ts已提交(本次无 Controller 变更,不适用)安全考虑
相关 Issue
Closes #238
测试说明
本地验证步骤
OAUTH2_GITHUB_CLIENT_ID与OAUTH2_GITHUB_CLIENT_SECRET。/api/v1/auth/me返回 200。回归测试范围
/api/v1/auth/me登录态读取。截图/录屏(如有 UI 变更)