Files
caikai-assets/docs/SSO_BROWSER_SESSION.md
liujjandClaude Opus 5.5 2072c6780f
CI / build-and-test (push) Canceled after 0s
feat: 资产管理前端从管理端拆分为独立工程
以 ckcloudManage a44810c 为基础,只保留资产页面(台账、单据、基础数据、同步任务)、
登录/错误/个人资料等公共页面,以及资产单据“查看流程”用到的流程详情页;
统一登录应用编码默认 CK_ASSET,标题“资产管理”,本地端口 9090。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 03:44:26 -08:00

5.8 KiB

SSO browser-session contract

  • Login and logout URL creation are POST requests with a cryptographically random 32-byte requestId. The initial login requestId is the browser transaction ID; there is no additional state parameter in the Ticket SSO protocol. The callback returns ticket and requestId; logout returns logout=1 and requestId. Ticket exchange sends the original ID as loginRequestId. The adapter generates a different requestId for its signed center exchange request, preserving replay protection. Browser requests include credentials for the HttpOnly binding.
  • The frontend requestId check is supplementary. The backend must independently bind and consume each transaction; a valid ticket by itself is insufficient.
  • Login and logout transactions have an 8-hour client lifetime matching the center recovery window, are bound to the originating tab and login generation, and are superseded by a newer transaction for this application. Callback errors remain visible until explicit user retry.
  • Access/refresh tokens, login generation and center-session binding are written as one application-namespaced localStorage record. Refresh preserves the generation and center binding. Other tabs reload identity and menus when the generation changes; old-page requests and old-generation responses are rejected.
  • Logout URL creation uses Origin, browser binding, requestId and the captured center generation, not a currently valid access token. Application logout sends the captured token without automatic refresh. Flow creation, login commits, logout cleanup, refresh, revoked-session cleanup and account-switch actions share the same Web Lock and recheck the captured flow or session after acquiring it. The backend must also resolve a replaced access token to its original refresh-token family. The center URL is bound to the captured opaque center-session generation, so a delayed logout cannot clear a newer center session.
  • Callback and local authentication URLs use Vite BASE_URL. The registered application callback must exactly match the deployed base path.
  • Legacy unnamespaced tokens are intentionally not migrated: their owning application cannot be established safely. Deployment requires a fresh login.
  • Browser flow storage uses v2 keys and does not accept previous state-based transactions. Historical OAuth and social-login state parameters remain unchanged.
  • The standalone center page at /zcy/login is not coupled to the management application's local login generation. Its captcha requests carry no management token; its form is bound by the backend's HttpOnly cookie and login token.
  • Sliding captcha is temporarily disabled (2026-10-24). UnifiedLogin.vue reads VITE_APP_CAPTCHA_ENABLE; when false, it submits the account/password form directly and does not mount the captcha widget. The backend ckcloud.captcha.enable must also be false. To restore captcha, enable both switches and restart/rebuild the affected services.
  • Changing an existing mobile number or email address prompts for currentPassword without storing it in the profile or login cache. Successful sensitive changes revoke sessions and send the user directly to forced login.
  • Profile password changes also revoke all sessions. The success event carries the pre-request session snapshot; cleanup and forced login occur under the shared lock only if that login generation is still current.
  • HTTPS and same-site deployment of the frontend and first-party adapter are required for browser cookie binding. CORS must allow the exact frontend origin with credentials, never a credentialed wildcard.
  • A modern browser with the Web Locks API is required by default. Unsupported browsers or insecure origins display an explicit error and cannot change login state. A dedicated HTTP test artifact may explicitly set VITE_ALLOW_INSECURE_HTTP_SSO=true; it serializes writes only within the current page and therefore must not be used for production or concurrent cross-tab account switching. Token writes and removals still assert lock ownership.
  • Test artifacts may set VITE_SSO_CENTER_PORT_MAP (for example, 8081:9000,1081:2000) so browser redirects use the matching internal or externally mapped identity-center port. This is an automatic exact port map; users never choose a center and production artifacts leave it unset.
  • Requests capture one session snapshot before checking the page generation and use only that snapshot's token. An old page cannot adopt another tab's new identity between the page check and the Authorization header assignment.

Focused manual acceptance

Logout URL or server revocation failures do not prevent local cleanup. Each failure path rechecks the captured flow and session before clearing storage. The callback displays an explicit incomplete-revocation warning; a stale logout must still abort without deleting a newer login. Local-only completion never claims all application or center sessions were revoked.

No automated tests or builds were executed for this hardening change.

  1. Login each application with an independent requestId and ensure same-origin deployment does not overwrite the other application's token or tenant/user cache.
  2. Reject absent, mismatched, expired, replayed and foreign-browser callback requestId.
  3. Start two login attempts; only the current transaction may commit locally.
  4. Change account in a second tab while requests are pending; reload the first tab without displaying the old identity with the new account's data.
  5. Logout while refresh is pending, then login in another tab. Old logout responses and callbacks must not remove the new session.
  6. Confirm revoked application access stops at an error page without a login loop.
  7. Verify callbacks and retry links when deployed at a non-root base path.