260706_2_로그인 인증 검토

This commit is contained in:
2026-07-07 20:40:10 +09:00
parent f8633bb1fe
commit 5da0260be3
29 changed files with 720 additions and 336 deletions
+11 -1
View File
@@ -90,7 +90,9 @@ async def verify_session(request: Request) -> dict[str, Any]:
now = datetime.utcnow()
expired = now > row[3] or (now - row[4]).total_seconds() > SESSION_IDLE_TIMEOUT_SECONDS
if expired or row[10] != "ACTIVE":
# NO_COMPANY(이메일 인증 완료·회사 미연결)도 로그인 유지 대상. 회사 연결 강제는
# require_company 의존성에서 별도 처리한다.
if expired or row[10] not in ("ACTIVE", "NO_COMPANY"):
await cursor.execute("DELETE FROM sessions WHERE id = %s", (session_id,))
await connection.commit()
raise HTTPException(status_code=401, detail="세션이 만료되었습니다.")
@@ -135,3 +137,11 @@ async def require_system_admin(
if session["role"] != "SYSTEM_ADMIN":
raise HTTPException(status_code=403, detail="시스템 관리자 권한이 필요합니다.")
return session
async def require_company(
session: dict[str, Any] = Depends(verify_session),
) -> dict[str, Any]:
if session["company_id"] is None:
raise HTTPException(status_code=403, detail="회사 연결이 필요합니다.")
return session