feat(sso): dbx-main SSO 통합, /corm/ 서브경로 호스팅, 인증 미들웨어 적용
- SessionMiddleware 추가 (dbx-main/OMS 와 동일 SECRET_KEY/COOKIE_NAME/MAX_AGE).
미설정 시 fail-fast.
- AuthGuardMiddleware: 미인증 시 HTML 요청은 dbx-main /login?next=... 으로 302,
API 요청은 401 JSON. 예외 경로: /static/, /health, OAuth 콜백, /login, /logout.
- /health/db 엔드포인트 추가 (DB ping) — dbx-main 헬스 배지가 폴링.
- /login, /logout 라우트 추가 (자체 OAuth 없음, dbx-main 으로 302 위임).
- APP_ROOT_PATH 환경변수 도입 — Dockerfile 의 uvicorn --root-path 로 전달.
- templates/index.html: 모든 /static/, /js 절대경로를 {{ root_path }} 기반으로,
window.APP_BASE_PATH 변수 주입.
- static/js/app.js: fetch wrapper 1개로 /api/* 호출에 APP_BASE_PATH prepend,
401 응답 시 dbx-main 로그인으로 자동 이동. 32 곳 호출 사이트는 그대로 둠.
- Cafe24 OAuth 콜백의 hard-coded redirect 도 root_path 인지하도록 수정.
- docker-compose.yml: 호스트 포트 바인딩 제거(0.0.0.0:8002 노출 차단),
expose 추가, web_net(npm_default) 외부 네트워크 attach, healthcheck 추가.
- .env.example 에 SSO/네트워크 항목 추가.
This commit is contained in:
@@ -1,4 +1,25 @@
|
||||
|
||||
// ============================================================
|
||||
// 서브경로 호스팅 — fetch wrapper
|
||||
// 모든 /api/* 호출에 APP_BASE_PATH 를 prepend, 401 응답 시 dbx-main 로그인으로 이동.
|
||||
// ============================================================
|
||||
(function () {
|
||||
const APP_BASE_PATH = (window.APP_BASE_PATH || '').replace(/\/$/, '');
|
||||
const origFetch = window.fetch.bind(window);
|
||||
window.fetch = async function (input, init) {
|
||||
if (typeof input === 'string' && APP_BASE_PATH && input.startsWith('/api/')) {
|
||||
input = APP_BASE_PATH + input;
|
||||
}
|
||||
const response = await origFetch(input, init);
|
||||
if (response.status === 401) {
|
||||
// 세션 만료 — dbx-main 로그인으로 위임 (next 로 현재 위치 보존)
|
||||
const next = encodeURIComponent((APP_BASE_PATH || '') + window.location.pathname + window.location.search);
|
||||
window.location.href = (APP_BASE_PATH || '') + '/login?next=' + next;
|
||||
}
|
||||
return response;
|
||||
};
|
||||
})();
|
||||
|
||||
function showToast(message) {
|
||||
const toast = document.createElement('div');
|
||||
toast.textContent = message;
|
||||
|
||||
Reference in New Issue
Block a user