Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions deploy/scripts/provision-console-preview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ else
PORT=${WEB_PORT}
NODE_ENV=production
SERVICE_OPS_API_BASE_URL=http://127.0.0.1:${API_PORT}
# 프리뷰는 평문 HTTP 라 Secure 쿠키가 브라우저에 저장되지 않는다. 그러면 로그인 직후
# 화면은 보이지만 다음 요청부터 세션이 없어 /login 으로 되돌아간다.
# **운영 env 에는 절대 넣지 않는다.** 프리뷰에 TLS 를 붙이면 이 줄을 지운다.
SERVICE_OPS_COOKIE_INSECURE=true
${map_lines}
EOF_WEB
log "${WEB_ENV} 작성 (600)"
Expand Down
19 changes: 19 additions & 0 deletions development/frontend/lib/services/service-ops-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,25 @@ export async function logoutServiceOpsSession(): Promise<void> {
});
}

/**
* 세션 쿠키에 `Secure` 를 붙일지.
*
* 기본은 운영 빌드에서 항상 붙인다. 다만 **평문 HTTP 로 접근하는 프리뷰**에서는 브라우저가
* Secure 쿠키를 저장하지 않아 로그인 직후 화면은 보이지만 다음 요청부터 세션이 없어
* `/login` 으로 되돌아간다. 인증이 필요한 QA 자체가 불가능해진다.
*
* `next start` 가 NODE_ENV 를 production 으로 강제하므로 env 에서 지우는 것으로는 풀리지
* 않는다. 그래서 명시적 옵트아웃을 둔다.
*
* **이 변수는 프리뷰 전용이다.** 설정하지 않으면 운영 동작이 그대로이고, 이름에
* `INSECURE` 를 넣어 무엇을 포기하는지 드러냈다. 운영 호스트의 env 에는 절대 넣지 않는다 —
* 넣으면 관리자 세션 쿠키가 평문으로 흐른다.
*
* 근본 해결은 프리뷰에 TLS 를 붙이는 것이다. 그때 이 변수를 지운다.
*/
function serviceOpsCookieSecure(): boolean {
if (process.env.SERVICE_OPS_COOKIE_INSECURE === "true") {
return false;
}
return process.env.NODE_ENV === "production";
}
Loading