diff --git a/README.md b/README.md index daca8f1..f0e474e 100644 --- a/README.md +++ b/README.md @@ -113,8 +113,9 @@ Worker 교체나 예외 종료로 `processing`, `ui_timeout_pending` 상태가 ## 보안 - 차량 API는 API token 또는 허용 IP 정책을 사용합니다. -- 차량 모니터 화면과 `monitor.php?mode=ajax`, `monitor.php?mode=usage`는 런처 공통 인증 쿠키가 유효할 때만 응답합니다. -- 런처 공통 인증은 `https://chaegeon.com/custom/launcher/api.php?session=1` 응답으로 확인하며, `/mnt` 아래 NFS 마운트 경로를 런타임 fallback으로 사용하지 않습니다. +- 차량 모니터 화면과 `monitor.php?mode=ajax`, `monitor.php?mode=usage`는 런처 공통 인증 쿠키 또는 사이트 관리자 세션이 유효할 때만 응답합니다. +- 사이트 관리자 세션이 확인되면 공통 인증 쿠키를 장기로 발급해 PWA에서 반복 인증이 뜨는 일을 줄입니다. +- 런처 공통 인증은 우선 공통 인증 모듈로 직접 확인하고, 필요 시 `https://chaegeon.com/custom/launcher/api.php?session=1` 응답으로 확인합니다. - 차량 제어 명령은 허용된 명령 코드로 제한합니다. - Secret 파일은 저장소 밖에서 제한된 권한으로 유지합니다. - 실제 제어 명령은 최신 상태 조회와 명령 검증 이후에만 전송합니다. diff --git a/monitor.php b/monitor.php index 2b4cf17..13b30ea 100644 --- a/monitor.php +++ b/monitor.php @@ -548,6 +548,24 @@ function car_monitor_launcher_session(): array return $session; } + $commonAuth = '/mnt/synology-web/custom/common/auth.php'; + if (is_readable($commonAuth)) { + require_once $commonAuth; + + if (function_exists('custom_has_auth_cookie') && custom_has_auth_cookie()) { + $session = ['authenticated' => true, 'admin' => false]; + return $session; + } + + if (function_exists('custom_is_site_admin') && custom_is_site_admin()) { + if (function_exists('custom_issue_auth_cookie')) { + custom_issue_auth_cookie(); + } + $session = ['authenticated' => true, 'admin' => true]; + return $session; + } + } + $cookieHeader = trim((string)($_SERVER['HTTP_COOKIE'] ?? '')); if ($cookieHeader === '') { $session = ['authenticated' => false, 'admin' => false]; @@ -629,8 +647,6 @@ a{display:inline-flex;align-items:center;justify-content:center;min-height:44px;

인증이 필요합니다

-

런처에서 관리자 세션 또는 공통 비밀번호 인증을 완료한 뒤 차량 모니터에 접속할 수 있습니다.

-런처로 이동