From 758158e81679e9092ddf1faefb7fe21280f52601 Mon Sep 17 00:00:00 2001 From: seo Date: Fri, 3 Jul 2026 14:18:05 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B0=A8=EB=9F=89=20=EB=AA=A8=EB=8B=88?= =?UTF-8?q?=ED=84=B0=20PWA=20=EC=A7=84=EC=9E=85=20=EC=9D=B8=EC=A6=9D=20?= =?UTF-8?q?=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + assets/site.webmanifest | 2 +- monitor.php | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bc0febb..a78604f 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ Worker 교체나 예외 종료로 `processing`, `ui_timeout_pending` 상태가 - 차량 API는 API token 또는 허용 IP 정책을 사용합니다. - 차량 모니터 화면과 `monitor.php?mode=ajax`, `monitor.php?mode=usage`는 런처 공통 인증 쿠키 또는 사이트 관리자 세션이 유효할 때만 응답합니다. - 공통 암호로 로그인한 일반 인증은 30분 유지하고, 사이트 관리자 세션이 확인되면 관리자 장기 쿠키를 발급해 PWA에서 반복 인증이 뜨는 일을 줄입니다. +- PWA로 설치한 차량 모니터는 manifest 시작 URL `/car/monitor.php?pwa=1`로 진입합니다. 이 요청은 공통 인증 쿠키를 한 번 발급한 뒤 `/car/monitor.php`로 되돌아가므로 설치형 앱 진입 때 반복 PIN 화면이 뜨는 일을 줄입니다. - 런처 공통 인증은 우선 공통 인증 모듈로 직접 확인합니다. 공통 모듈을 사용할 수 없는 경우에만 `https://chaegeon.com/custom/launcher/api.php?session=1` 응답으로 확인합니다. - 브라우저로 직접 접근했는데 인증이 없으면 채건닷컴으로 보내지 않고 `/custom/common/js/auth-pin.js`의 4자리 숫자 PIN 화면을 표시합니다. 차량 모니터는 `seo.chaegeon.com`에서 동작하므로 화면 입력값을 `monitor.php?mode=auth-login`으로 보내 공통 암호를 검증하고, 인증이 끝나면 차량 모니터를 다시 불러옵니다. - 차량 모니터의 브라우저 화면 인증은 런처/나의 찾기와 같은 공통 쿠키를 사용하지만, 차량 단말이 호출하는 `api.php` 인증은 API token과 허용 IP 정책을 사용하는 별도 경로입니다. diff --git a/assets/site.webmanifest b/assets/site.webmanifest index 40e336b..a3caf87 100644 --- a/assets/site.webmanifest +++ b/assets/site.webmanifest @@ -2,7 +2,7 @@ "name": "Car Monitor", "short_name": "Car Monitor", "description": "Vehicle status monitor", - "start_url": "/car/monitor.php", + "start_url": "/car/monitor.php?pwa=1", "scope": "/car/", "display": "standalone", "orientation": "portrait", diff --git a/monitor.php b/monitor.php index 0c6d480..7c72ddd 100644 --- a/monitor.php +++ b/monitor.php @@ -982,6 +982,31 @@ window.addEventListener('DOMContentLoaded', function () { exit; } +function car_monitor_issue_pwa_cookie_if_requested(): void +{ + if (($_GET['pwa'] ?? '') !== '1') { + return; + } + + $fetchDest = strtolower((string)($_SERVER['HTTP_SEC_FETCH_DEST'] ?? '')); + if ($fetchDest !== '' && $fetchDest !== 'document') { + return; + } + + $commonAuth = '/mnt/synology-web/custom/common/auth.php'; + if (!is_readable($commonAuth)) { + return; + } + + require_once $commonAuth; + if (function_exists('custom_issue_auth_cookie')) { + custom_issue_auth_cookie(false); + } + + header('Location: /car/monitor.php', true, 302); + exit; +} + function car_monitor_auth_api(): void { $commonAuth = '/mnt/synology-web/custom/common/auth.php'; @@ -1016,6 +1041,8 @@ if (isset($_GET['mode']) && $_GET['mode'] === 'auth-login') { car_monitor_auth_api(); } +car_monitor_issue_pwa_cookie_if_requested(); + if (isset($_GET['mode']) && $_GET['mode'] === 'ajax') { car_monitor_require_access(true);