feat(sso): 인앱 브라우저 SSO 토큰 릴레이 — 카톡 WebView 쿠키 미공유 해결

카카오톡 인앱 WebView는 서브도메인 간 쿠키를 공유하지 않아
tkds에서 로그인 후 tkfb로 리다이렉트 시 인증이 풀리는 문제.

- sso-relay.js: URL hash의 _sso= 토큰을 로컬 쿠키+localStorage로 설정
- gateway dashboard: 로그인 후 redirect URL에 #_sso=<token> 추가
- 전 서비스 HTML: core JS 직전에 sso-relay.js 로드 (81개 파일)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-04-01 15:44:02 +09:00
parent de6d918d42
commit 0de9d5bb48
90 changed files with 398 additions and 3 deletions

View File

@@ -133,6 +133,7 @@
</div>
</div>
<script src="/static/js/sso-relay.js?v=20260401"></script>
<script src="/static/js/tkpurchase-core.js?v=2026040101"></script>
<script src="/static/js/tkpurchase-accounts.js?v=2026031601"></script>
<script>initAccountsPage();</script>

View File

@@ -148,6 +148,7 @@
</div>
</div>
<script src="/static/js/sso-relay.js?v=20260401"></script>
<script src="/static/js/tkpurchase-core.js?v=2026040101"></script>
<script src="/static/js/tkpurchase-daylabor.js?v=2026031601"></script>
<script>initDayLaborPage();</script>

View File

@@ -88,6 +88,7 @@
</div>
</div>
<script src="/static/js/sso-relay.js?v=20260401"></script>
<script src="/static/js/tkpurchase-core.js?v=2026040101"></script>
<script src="/static/js/tkpurchase-dashboard.js?v=2026031601"></script>
<script>initDashboard();</script>

View File

@@ -61,6 +61,7 @@
<div id="historyPagination" class="mt-4 flex justify-center gap-2"></div>
</div>
<script src="/static/js/sso-relay.js?v=20260401"></script>
<script src="/static/js/tkpurchase-core.js?v=2026040101"></script>
<script src="/static/js/tkpurchase-partner-history.js?v=2026031602"></script>
<script>initPartnerHistory();</script>

View File

@@ -81,6 +81,7 @@
</div>
</div>
<script src="/static/js/sso-relay.js?v=20260401"></script>
<script src="/static/js/tkpurchase-core.js?v=2026040101"></script>
<script src="/static/js/tkpurchase-partner-portal.js?v=2026031602"></script>
<script>initPartnerPortal();</script>

View File

@@ -294,6 +294,7 @@
</div>
</div>
<script src="/static/js/sso-relay.js?v=20260401"></script>
<script src="/static/js/tkpurchase-core.js?v=2026040101"></script>
<script src="/static/js/tkpurchase-partner.js?v=2026031601"></script>
<script>initPartnerPage();</script>

View File

@@ -275,6 +275,7 @@
</div>
</div>
<script src="/static/js/sso-relay.js?v=20260401"></script>
<script src="/static/js/tkpurchase-core.js?v=2026040101"></script>
<script src="/static/js/tkpurchase-schedule.js?v=2026031602"></script>
<script>initSchedulePage();</script>

View File

@@ -0,0 +1,39 @@
/**
* SSO Token Relay — 인앱 브라우저(카카오톡 등) 서브도메인 쿠키 미공유 대응
*
* Canonical source: shared/frontend/sso-relay.js
* 전 서비스 동일 코드 — 수정 시 아래 파일 <20><><EFBFBD>체 갱신 필요:
* 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=<token>을 붙여 전달.
*/
(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);
})();

View File

@@ -100,6 +100,7 @@
</div>
</div>
<script src="/static/js/sso-relay.js?v=20260401"></script>
<script src="/static/js/tkpurchase-core.js?v=2026040101"></script>
<script src="/static/js/tkpurchase-workreport-summary.js?v=2026031601"></script>
<script>initSummaryPage();</script>

View File

@@ -114,6 +114,7 @@
</div>
</div>
<script src="/static/js/sso-relay.js?v=20260401"></script>
<script src="/static/js/tkpurchase-core.js?v=2026040101"></script>
<script src="/static/js/tkpurchase-workreport.js?v=2026031601"></script>
<script>initWorkReportPage();</script>