From 1efe2dbe8910192bc1890f6b91cc22696a9e08b1 Mon Sep 17 00:00:00 2001 From: bicochan Date: Fri, 31 Jul 2026 17:56:21 +0900 Subject: [PATCH] =?UTF-8?q?remove:=20ClientIpGuard=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/src/lib/client-ip-guard.tsx | 59 ------------------- .../common/components/src/ui/layout/base.tsx | 41 ++++++------- .../components/src/ui/layout/nofooter.tsx | 35 +++++------ .../common/components/src/ui/layout/nolnb.tsx | 30 ++++------ packages/common/network/tsconfig.json | 8 +-- 5 files changed, 50 insertions(+), 123 deletions(-) delete mode 100644 packages/common/components/src/lib/client-ip-guard.tsx diff --git a/packages/common/components/src/lib/client-ip-guard.tsx b/packages/common/components/src/lib/client-ip-guard.tsx deleted file mode 100644 index d1ae1735c..000000000 --- a/packages/common/components/src/lib/client-ip-guard.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import { useEffect, useState } from "react"; -import { useQueryClient } from "@tanstack/react-query"; -import { getSiteInfo } from "../api/site"; -import { getIpList } from "../api/ip"; -import { ENDPOINT } from "../config"; -import { getCookie } from "../lib"; - -const siteId = getCookie("site-id-key") ?? ""; - -const ClientIpGuard = ({ - currentPath, - children, -}: { - currentPath?: string; - children: React.ReactNode; -}) => { - const queryClient = useQueryClient(); - const [clientIp, setClientIp] = useState(""); - const [isAllowed, setIsAllowed] = useState(true); - - useEffect(() => { - (async () => { - const response = await fetch("https://api.ipify.org?format=json"); - const data = await response.json(); - if (!data?.ip) return; - setClientIp(data.ip); - })(); - }, []); - - useEffect(() => { - (async () => { - if (!siteId || !clientIp) return; - - const siteInfo = await queryClient.ensureQueryData({ - queryKey: [ENDPOINT.CMS_SERVICE.SITES, siteId], - queryFn: () => getSiteInfo(siteId), - }); - - if (siteInfo.siteKndCd === "O") return; - - const { content: ipList } = await getIpList({ - siteId, - prmYn: "Y", - }); - - const allowedClientIp = ipList.some((ip) => ip.ipAddr === clientIp); - setIsAllowed(allowedClientIp); - })(); - }, [queryClient, clientIp, currentPath]); - - if (!isAllowed) { - alert("허용되지 않은 IP로 접근하였습니다."); - return <>; - } - - return <>{children}; -}; - -export { ClientIpGuard }; diff --git a/packages/common/components/src/ui/layout/base.tsx b/packages/common/components/src/ui/layout/base.tsx index 58b678b25..994e1016d 100644 --- a/packages/common/components/src/ui/layout/base.tsx +++ b/packages/common/components/src/ui/layout/base.tsx @@ -3,7 +3,6 @@ import type { QueryClient } from "@tanstack/react-query"; import { QueryProvider } from "../../provider/query-provider"; import { PopupProvider } from "../../provider/popup-provider"; import { HelpDialogProvider } from "../../provider/help-dialog-context"; -import { ClientIpGuard } from "../../lib/client-ip-guard"; import type { MenuItem } from "../../api"; import { SidebarProvider } from "../sidebar"; import { LNB } from "../lnb"; @@ -29,30 +28,28 @@ export function BaseLayout({ }) { return ( - - - - -
-
+ + +
+
+
+ -
- -
-
{children}
-
-
+
+
{children}
+
- - - - +
+ + + ); } diff --git a/packages/common/components/src/ui/layout/nofooter.tsx b/packages/common/components/src/ui/layout/nofooter.tsx index 29b5cddf6..7ee096c72 100644 --- a/packages/common/components/src/ui/layout/nofooter.tsx +++ b/packages/common/components/src/ui/layout/nofooter.tsx @@ -2,7 +2,6 @@ import type { QueryClient } from "@tanstack/react-query"; import { QueryProvider } from "../../provider/query-provider"; import { PopupProvider } from "../../provider/popup-provider"; import { HelpDialogProvider } from "../../provider/help-dialog-context"; -import { ClientIpGuard } from "../../lib/client-ip-guard"; import type { MenuItem } from "../../api"; import { SidebarProvider } from "../sidebar"; import { LNB } from "../lnb"; @@ -25,26 +24,24 @@ export function NoFooterLayout({ }) { return ( - - - - -
-
-
- -
-
{children}
-
+ + + +
+
+
+ +
+
{children}
- - - - +
+
+
+
); } diff --git a/packages/common/components/src/ui/layout/nolnb.tsx b/packages/common/components/src/ui/layout/nolnb.tsx index 57c346ed0..c64cef3c9 100644 --- a/packages/common/components/src/ui/layout/nolnb.tsx +++ b/packages/common/components/src/ui/layout/nolnb.tsx @@ -3,7 +3,6 @@ import type { QueryClient } from "@tanstack/react-query"; import { QueryProvider } from "../../provider/query-provider"; import { PopupProvider } from "../../provider/popup-provider"; import { HelpDialogProvider } from "../../provider/help-dialog-context"; -import { ClientIpGuard } from "../../lib/client-ip-guard"; import type { MenuItem } from "../../api"; import { SidebarProvider } from "../sidebar"; import { Header } from "../header"; @@ -14,7 +13,6 @@ export function NoLNBLayout({ children, queryClient, authService, - currentPath, }: { children: React.ReactNode; queryClient?: QueryClient; @@ -24,23 +22,21 @@ export function NoLNBLayout({ }) { return ( - - - - -
-
-
-
-
{children}
-
-
+ + + +
+
+
+
+
{children}
+
- - - - +
+
+
+
); } diff --git a/packages/common/network/tsconfig.json b/packages/common/network/tsconfig.json index 0468315bf..ec4a9e559 100644 --- a/packages/common/network/tsconfig.json +++ b/packages/common/network/tsconfig.json @@ -3,13 +3,9 @@ "extends": "../../../tsconfig.base.json", "compilerOptions": { "module": "ESNext", + "moduleResolution": "bundler", "types": ["node"] }, "include": ["."], - "exclude": [ - "node_modules", - "dist", - "coverage", - "storybook-static" - ] + "exclude": ["node_modules", "dist", "coverage", "storybook-static"] }