06af036f86
Windows tray app (desktop/notifier, C# .NET Framework 4.8 WinForms, single exe, no installer/admin) that shows the same big alert popup as the web even when the browser is in the background: layered topmost window that does not steal focus, blinking border, open/close actions, sound, autostart toggle, DPAPI-encrypted token. Server side (project_db migration 023): - notifier_links / notifier_tokens (SHA-256 hashes only) - device link flow: link/start -> browser approve at /project/notifier -> link/poll issues token once - Bearer API for alerts/read/logout reusing _alerts_payload; token re-checks current user record and project permission each call - /project/notifier page (approve, connected PCs, revoke, download) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
2.7 KiB
PL/PgSQL
45 lines
2.7 KiB
PL/PgSQL
-- =====================================================================
|
|
-- project_db 마이그레이션 023 — PC 알림 프로그램(DBX 알림) 연결
|
|
-- =====================================================================
|
|
-- 멱등(idempotent). 테이블만 추가한다(기존 값 변경·삭제 없음). 운영: /opt/www/main 에서 기존 project_db 에 적용.
|
|
--
|
|
-- 왜(2026-10-08 사용자 요청): 웹브라우저가 뒤에 있어도 태그·작업 배정 알림을 PC 화면 위에 크게 띄우는
|
|
-- 트레이 프로그램(desktop/notifier). 브라우저 세션(쿠키)을 쓸 수 없으므로 PC마다 연결 토큰을 발급한다.
|
|
-- ① 프로그램이 연결 요청(notifier_links: 화면 코드 + 확인용 poll 비밀값) → ② 사용자가 브라우저(로그인 상태)에서
|
|
-- 코드를 확인하고 [연결] → ③ 프로그램이 poll 로 토큰을 한 번 받는다(notifier_tokens). 토큰·poll 값은 원문을
|
|
-- 저장하지 않고 SHA-256 해시만 저장한다. 연결 해제 = revoked_at.
|
|
-- =====================================================================
|
|
BEGIN;
|
|
|
|
CREATE TABLE IF NOT EXISTS notifier_links (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
code TEXT NOT NULL UNIQUE, -- 화면에 보이는 짧은 코드(예: K7QM-4XPA)
|
|
poll_hash TEXT NOT NULL UNIQUE, -- 프로그램만 아는 poll 비밀값의 SHA-256
|
|
device_name TEXT NOT NULL DEFAULT '',
|
|
email TEXT NULL, -- [연결]을 누른 사용자(승인 전 NULL)
|
|
approved_at TIMESTAMPTZ NULL,
|
|
consumed_at TIMESTAMPTZ NULL, -- 토큰을 내준 시각(한 번만)
|
|
expires_at TIMESTAMPTZ NOT NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|
|
CREATE INDEX IF NOT EXISTS idx_notifier_links_expires ON notifier_links (expires_at);
|
|
COMMENT ON TABLE notifier_links IS 'PC 알림 프로그램 연결 요청 — 10분 유효, 승인 후 토큰 1회 발급';
|
|
|
|
CREATE TABLE IF NOT EXISTS notifier_tokens (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
email TEXT NOT NULL,
|
|
token_hash TEXT NOT NULL UNIQUE, -- 토큰 원문의 SHA-256
|
|
device_name TEXT NOT NULL DEFAULT '',
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
last_seen_at TIMESTAMPTZ NULL,
|
|
revoked_at TIMESTAMPTZ NULL
|
|
);
|
|
CREATE INDEX IF NOT EXISTS idx_notifier_tokens_email ON notifier_tokens (email);
|
|
COMMENT ON TABLE notifier_tokens IS 'PC 알림 프로그램 토큰 — 사용자·PC 단위, revoked_at 이면 해제';
|
|
|
|
GRANT SELECT, INSERT, UPDATE, DELETE ON notifier_links, notifier_tokens TO project_app;
|
|
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO project_app;
|
|
|
|
COMMIT;
|
|
SELECT 'project_db 023 notifier ready' AS status;
|