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:
Hyungi Ahn
2026-02-09 18:41:44 +09:00
parent 550633b89d
commit 6495b8af32
114 changed files with 1729 additions and 4335 deletions

View File

@@ -621,18 +621,32 @@
});
}
// 쿠키 헬퍼
function _ckGet(name) {
var m = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
return m ? decodeURIComponent(m[1]) : null;
}
function _ckRemove(name) {
var c = name + '=; path=/; max-age=0';
if (window.location.hostname.includes('technicalkorea.net')) c += '; domain=.technicalkorea.net';
document.cookie = c;
}
function _centralLoginUrl() {
var h = window.location.hostname;
if (h.includes('technicalkorea.net')) return window.location.protocol + '//tkfb.technicalkorea.net/login?redirect=' + encodeURIComponent(window.location.href);
return window.location.protocol + '//' + h + ':30000/login?redirect=' + encodeURIComponent(window.location.href);
}
// 수동 초기화 함수 (initializeApp 함수가 로드되지 않을 때 사용)
async function manualInitialize() {
console.log('🔧 수동 초기화 시작');
// 토큰이 있으면 사용자 정보 가져오기
const token = localStorage.getItem('access_token');
// SSO 쿠키 우선, localStorage 폴백
const token = _ckGet('sso_token') || localStorage.getItem('sso_token') || localStorage.getItem('access_token');
if (token) {
try {
// 토큰으로 사용자 정보 가져오기 (API 호출)
const user = await AuthAPI.getCurrentUser();
currentUser = user;
// localStorage에도 백업 저장
localStorage.setItem('currentUser', JSON.stringify(user));
@@ -670,8 +684,10 @@
} catch (error) {
console.error('수동 초기화 실패:', error);
// 토큰이 유효하지 않으면 로그아웃
_ckRemove('sso_token'); _ckRemove('sso_user'); _ckRemove('sso_refresh_token');
localStorage.removeItem('access_token');
localStorage.removeItem('sso_token');
localStorage.removeItem('sso_user');
localStorage.removeItem('currentUser');
}
}
@@ -721,17 +737,14 @@
handleUrlHash();
} else {
console.log('❌ 인증되지 않은 사용자 - 로그인 화면 표시');
// 로그인이 필요한 경우 로그인 화면 표시
document.getElementById('loginScreen').classList.remove('hidden');
document.getElementById('mainScreen').classList.add('hidden');
// 인증되지 않은 사용자 → 중앙 로그인으로
window.location.href = _centralLoginUrl();
return;
}
} catch (error) {
console.error('앱 초기화 실패:', error);
// 에러 발생 시 로그인 화면 표시
document.getElementById('loginScreen').classList.remove('hidden');
document.getElementById('mainScreen').classList.add('hidden');
console.error('앱 초기화 실패:', error);
window.location.href = _centralLoginUrl();
}
}