feat(project): projects visible to members only, admins included

Admins no longer see projects they are not owner/member of: sidebar list,
project list API, project pages, search, inbox, notifications, reminders
and trash all follow access.visible_project_ids. Only the super admin
still sees every project. Member assignment stays admin-only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-07 14:16:36 +09:00
parent 2a01d97dd0
commit b6dc82c0b3
7 changed files with 122 additions and 26 deletions
+17 -9
View File
@@ -5,7 +5,9 @@
바꾸지도 알림을 받지도 않는다(기록 자체는 업무 이력으로 남긴다).
프로젝트
관리(=보기·작업 CRUD) : 관리자(is_admin) · 프로젝트 owner · 배정 멤버. 모두 `project` 모듈 권한이 있어야 한다.
관리(=보기·작업 CRUD) : 프로젝트 owner · 배정 멤버 · 슈퍼관리자. 모두 `project` 모듈 권한이 있어야 한다.
(2026-10-07 — 관리자(is_admin)도 멤버가 아닌 프로젝트는 보이지 않는다. 예외는 슈퍼관리자 한 명뿐.
멤버 배정 자체는 여전히 관리자만 — 라우터의 _require_admin.)
작업
FULL : 원 소속 프로젝트를 관리할 수 있음 → 보기·수정·댓글·첨부·삭제(삭제는 추가로 생성자 규칙)
@@ -34,10 +36,16 @@ def default_user_lookup(email: str) -> dict[str, Any] | None:
return user_store.get(store.norm_str(email, lower=True))
def _is_admin(user: dict[str, Any] | None) -> bool:
from app.store import is_admin # noqa: WPS433
def _is_super(user: dict[str, Any] | None) -> bool:
"""슈퍼관리자(app.store.SUPER_ADMIN_EMAIL) — 모든 프로젝트를 보는 유일한 예외."""
from app.store import SUPER_ADMIN_EMAIL # noqa: WPS433
return is_admin(user)
return bool(user) and email_of(user) == SUPER_ADMIN_EMAIL
def sees_all_projects(user: dict[str, Any] | None) -> bool:
"""멤버가 아니어도 모든 프로젝트를 보는가 — 슈퍼관리자만(모듈 권한도 있어야)."""
return can_use_module(user) and _is_super(user)
def can_use_module(user: dict[str, Any] | None) -> bool:
@@ -51,10 +59,10 @@ def email_of(user: dict[str, Any] | None) -> str:
def can_manage_project(st: Any, user: dict[str, Any] | None, project_id: Any) -> bool:
"""프로젝트 관리(=보기·작업 CRUD) — 관리자 또는 owner/멤버. 모듈 권한이 없으면 False."""
"""프로젝트 관리(=보기·작업 CRUD) — owner/멤버(관리자도 마찬가지), 슈퍼관리자는 전부. 모듈 권한이 없으면 False."""
if not can_use_module(user):
return False
if _is_admin(user):
if _is_super(user):
return True
try:
pid = int(project_id)
@@ -64,11 +72,11 @@ def can_manage_project(st: Any, user: dict[str, Any] | None, project_id: Any) ->
def visible_project_ids(st: Any, user: dict[str, Any]) -> set[int] | None:
"""관리할 수 있는 프로젝트 id 집합. 관리자는 None(=전체)."""
if _is_admin(user):
return None
"""관리할 수 있는 프로젝트 id 집합. 슈퍼관리자는 None(=전체), 그 밖(관리자 포함)은 owner·멤버인 프로젝트만."""
if not can_use_module(user):
return set()
if _is_super(user):
return None
return {
int(p["id"]) for p in st.list_projects(include_archived=True, member_email=email_of(user))
}