Use server session check for access

This commit is contained in:
seo
2026-06-12 15:43:19 +09:00
parent 61866ef8d6
commit 5d73ac520b
2 changed files with 12 additions and 5 deletions
+2
View File
@@ -31,6 +31,8 @@ Home Assistant에 기록된 Galaxy 기기의 위치, 배터리, 활동 상태,
인증과 Home Assistant 호출은 `/custom/common`을 사용합니다. 브라우저 JS에는 더 이상 API Bearer 토큰이나 Home Assistant 웹훅 식별자를 직접 넣지 않습니다.
접근 확인은 JS에서 읽을 수 있는 레거시 쿠키가 아니라 `/custom/launcher/api.php?session=1` 서버 응답으로 처리합니다. 공통 인증 쿠키는 `HttpOnly`이므로 브라우저 스크립트가 직접 읽지 않습니다.
표시할 모바일 앱 센서 목록은 `/custom/common/config.php``findmydevice_sensor_sections`에서 섹션 단위로 관리합니다. 화면 CSS 원본은 `/custom/common/css/findmydevice.css`를 사용합니다. 기존 운영 HTML이 `/custom/findmydevice/css/style.css`를 참조해도 호환 파일이 공용 CSS를 import합니다.
## 운영 메모
+8 -3
View File
@@ -434,10 +434,15 @@ document.addEventListener('DOMContentLoaded', () => {
return (window.matchMedia('(display-mode: standalone)').matches) || (window.navigator.standalone === true);
}
// 조건: /findmydevice로 시작하고 access 쿠키가 없으며, PWA가 아닌 경우에만 리디렉션
if (location.pathname.startsWith('/findmydevice') && getCookie('access') !== '9KxH6236' && !isInStandaloneMode()) {
if (location.pathname.startsWith('/findmydevice') && !isInStandaloneMode()) {
fetch('/custom/launcher/api.php?session=1', { credentials: 'same-origin' })
.then(res => res.ok ? res.json() : Promise.reject())
.then(session => {
if (!session.authenticated) {
location.replace('/blog');
return; // 이하 코드 실행 방지
}
})
.catch(() => location.replace('/blog'));
}
const btnArea = document.querySelector('body > div.btnArea');