Files
caikai-assets/docs/SSO_BROWSER_SESSION.md
T

85 lines
5.8 KiB
Markdown
Raw Normal View History

# 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.