[grade=B] fix(auth): reuse valid session for cross-host SSO
This commit is contained in:
@@ -203,8 +203,22 @@ module.exports = function(deps) {
|
||||
}
|
||||
}, 'auth-app-token'));
|
||||
|
||||
// A browser that already has a valid status.sami session must not be asked
|
||||
// for TOTP again just because it opened another private-TLD service host.
|
||||
// Mint a fresh one-time token that the target host can exchange for its own
|
||||
// host-only cookie. This route is intentionally session-protected both by
|
||||
// the global middleware and here (defence in depth).
|
||||
router.get('/auth/sso-handoff', (req, res) => {
|
||||
res.setHeader('Cache-Control', 'no-store');
|
||||
if (!session.isValid(req)) {
|
||||
return errorResponse(res, 401, 'Session expired or invalid');
|
||||
}
|
||||
ok(res, { ssoToken: session.createHandoffToken() });
|
||||
});
|
||||
|
||||
// Cross-subdomain SSO handoff: exchanges a short-lived single-use token
|
||||
// (minted by /totp/verify) for a HOST-ONLY session cookie on whichever
|
||||
// (minted by /totp/verify or /auth/sso-handoff) for a HOST-ONLY session
|
||||
// cookie on whichever
|
||||
// *.sami origin calls this. Needed because Domain=.sami cookies are
|
||||
// silently rejected by real browsers (.sami is an unregistered TLD, so
|
||||
// browsers treat "sami" as the effective public suffix and refuse to set
|
||||
|
||||
Reference in New Issue
Block a user