/** * SSO Token Relay — 인앱 브라우저(카카오톡 등) 서브도메인 쿠키 미공유 대응 * * Canonical source: shared/frontend/sso-relay.js * 전 서비스 동일 코드 — 수정 시 아래 파일 ���체 갱신 필요: * system1-factory/web/js/sso-relay.js * system2-report/web/js/sso-relay.js * system3-nonconformance/web/static/js/sso-relay.js * user-management/web/static/js/sso-relay.js * tkpurchase/web/static/js/sso-relay.js * tksafety/web/static/js/sso-relay.js * tksupport/web/static/js/sso-relay.js * * 동작: URL hash에 _sso= 파라미터가 있으면 토큰을 로컬 쿠키+localStorage에 설정하고 hash를 제거. * gateway/dashboard.html에서 로그인 성공 후 redirect URL에 #_sso=을 붙여 전달. */ (function() { var hash = location.hash; if (!hash || hash.indexOf('_sso=') === -1) return; var match = hash.match(/[#&]_sso=([^&]*)/); if (!match) return; var token = decodeURIComponent(match[1]); if (!token) return; // 로컬(1st-party) 쿠키 설정 var cookie = 'sso_token=' + encodeURIComponent(token) + '; path=/; max-age=604800'; if (location.hostname.indexOf('technicalkorea.net') !== -1) { cookie += '; domain=.technicalkorea.net; secure; samesite=lax'; } document.cookie = cookie; // localStorage 폴백 try { localStorage.setItem('sso_token', token); } catch (e) {} // URL에서 hash 제거 history.replaceState(null, '', location.pathname + location.search); })();