feat: SSO 쿠키 인증 통합 + 서브도메인 라우팅 아키텍처
- Path-based 라우팅을 서브도메인 기반으로 전환 (tkfb/tkreport/tkqc.technicalkorea.net) - 3개 시스템 프론트엔드에 SSO 쿠키 인증 통합 (domain=.technicalkorea.net, localStorage 폴백) - Gateway: 포털+로그인+System1 프록시, 쿠키 SSO 설정 - System 1: 토큰키 통일, nginx.conf 생성, 신고페이지 리다이렉트 - System 2: api-base.js/app-init.js 생성, getSSOToken() 통합 - System 3: TokenManager 쿠키 지원, 중앙 로그인 리다이렉트 - docker-compose.yml에 cloudflared 서비스 추가 - DEPLOY-GUIDE.md 배포 가이드 작성 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -141,19 +141,19 @@
|
||||
<p>사용할 시스템을 선택하세요</p>
|
||||
</div>
|
||||
<div class="systems">
|
||||
<a href="/factory/" class="system-card s1" id="card-s1">
|
||||
<a href="/pages/dashboard.html" class="system-card s1" id="card-s1">
|
||||
<div class="system-icon">🏭</div>
|
||||
<h3>공장관리</h3>
|
||||
<p>작업보고, 근태관리, TBM, 순회점검, 장비관리 등 현장 운영 전반</p>
|
||||
<span class="badge">System 1</span>
|
||||
</a>
|
||||
<a href="/report/" class="system-card s2" id="card-s2">
|
||||
<a id="card-s2-link" class="system-card s2" id="card-s2">
|
||||
<div class="system-icon">🚨</div>
|
||||
<h3>신고 시스템</h3>
|
||||
<p>안전/부적합 이슈 신고, 처리현황 추적, 부적합 자동 연동</p>
|
||||
<span class="badge">System 2</span>
|
||||
</a>
|
||||
<a href="/nc/" class="system-card s3" id="card-s3">
|
||||
<a id="card-s3-link" class="system-card s3" id="card-s3">
|
||||
<div class="system-icon">📋</div>
|
||||
<h3>부적합 관리</h3>
|
||||
<p>부적합 이슈 접수, 처리, 리포트 생성, 프로젝트별 현황 관리</p>
|
||||
@@ -167,12 +167,31 @@
|
||||
|
||||
<script src="/shared/nav-header.js"></script>
|
||||
<script>
|
||||
const TOKEN_KEY = 'sso_token';
|
||||
const USER_KEY = 'sso_user';
|
||||
var ssoCookie = {
|
||||
get: function(name) {
|
||||
var match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
||||
return match ? decodeURIComponent(match[1]) : null;
|
||||
},
|
||||
remove: function(name) {
|
||||
var cookie = name + '=; path=/; max-age=0';
|
||||
if (window.location.hostname.includes('technicalkorea.net')) {
|
||||
cookie += '; domain=.technicalkorea.net';
|
||||
}
|
||||
document.cookie = cookie;
|
||||
}
|
||||
};
|
||||
|
||||
function getToken() {
|
||||
return ssoCookie.get('sso_token') || localStorage.getItem('sso_token');
|
||||
}
|
||||
function getUser() {
|
||||
var raw = ssoCookie.get('sso_user') || localStorage.getItem('sso_user');
|
||||
try { return JSON.parse(raw); } catch(e) { return null; }
|
||||
}
|
||||
|
||||
function init() {
|
||||
const token = localStorage.getItem(TOKEN_KEY);
|
||||
const user = JSON.parse(localStorage.getItem(USER_KEY) || 'null');
|
||||
var token = getToken();
|
||||
var user = getUser();
|
||||
|
||||
if (token && user) {
|
||||
showDashboard(user);
|
||||
@@ -199,12 +218,36 @@
|
||||
}
|
||||
|
||||
function logout() {
|
||||
localStorage.removeItem(TOKEN_KEY);
|
||||
localStorage.removeItem(USER_KEY);
|
||||
fetch('/auth/logout', { method: 'POST' }).catch(() => {});
|
||||
ssoCookie.remove('sso_token');
|
||||
ssoCookie.remove('sso_user');
|
||||
ssoCookie.remove('sso_refresh_token');
|
||||
localStorage.removeItem('sso_token');
|
||||
localStorage.removeItem('sso_user');
|
||||
localStorage.removeItem('sso_refresh_token');
|
||||
fetch('/auth/logout', { method: 'POST' }).catch(function(){});
|
||||
location.reload();
|
||||
}
|
||||
|
||||
// 서브도메인 링크 설정
|
||||
function setupSystemLinks() {
|
||||
var hostname = window.location.hostname;
|
||||
var protocol = window.location.protocol;
|
||||
var s2Link, s3Link;
|
||||
|
||||
if (hostname.includes('technicalkorea.net')) {
|
||||
s2Link = protocol + '//tkreport.technicalkorea.net';
|
||||
s3Link = protocol + '//tkqc.technicalkorea.net';
|
||||
} else {
|
||||
// 개발 환경: 포트 기반
|
||||
s2Link = protocol + '//' + hostname + ':30180';
|
||||
s3Link = protocol + '//' + hostname + ':30280';
|
||||
}
|
||||
|
||||
document.getElementById('card-s2-link').href = s2Link;
|
||||
document.getElementById('card-s3-link').href = s3Link;
|
||||
}
|
||||
setupSystemLinks();
|
||||
|
||||
init();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user