forked from baron/baron-sso
refactor: 어드민 프론트엔드에서 애플리케이션(RP) 목록 기능 제거 #239
This commit is contained in:
@@ -7,10 +7,6 @@ import AuthPage from "../features/auth/AuthPage";
|
||||
import DashboardPage from "../features/dashboard/DashboardPage";
|
||||
import GlobalOverviewPage from "../features/overview/GlobalOverviewPage";
|
||||
import LoginPage from "../features/auth/LoginPage";
|
||||
import RPDetailPage from "../features/relying-parties/routes/RPDetailPage";
|
||||
import RPListPage from "../features/relying-parties/routes/RPListPage";
|
||||
import RPOwnersTab from "../features/relying-parties/routes/RPOwnersTab";
|
||||
import RPProfileTab from "../features/relying-parties/routes/RPProfileTab";
|
||||
import TenantGroupCreatePage from "../features/tenant-groups/routes/TenantGroupCreatePage";
|
||||
import TenantGroupDetailPage from "../features/tenant-groups/routes/TenantGroupDetailPage";
|
||||
import TenantGroupListPage from "../features/tenant-groups/routes/TenantGroupListPage";
|
||||
@@ -68,15 +64,6 @@ export const router = createBrowserRouter(
|
||||
},
|
||||
{ path: "api-keys", element: <ApiKeyListPage /> },
|
||||
{ path: "api-keys/new", element: <ApiKeyCreatePage /> },
|
||||
{ path: "relying-parties", element: <RPListPage /> },
|
||||
{
|
||||
path: "relying-parties/:id",
|
||||
element: <RPDetailPage />,
|
||||
children: [
|
||||
{ index: true, element: <RPProfileTab /> },
|
||||
{ path: "owners", element: <RPOwnersTab /> },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -25,11 +25,9 @@ import {
|
||||
to: "/dashboard",
|
||||
icon: ShieldHalf,
|
||||
},
|
||||
{ label: "ui.admin.nav.tenant_groups", to: "/tenant-groups", icon: LayoutGrid },
|
||||
{ label: "ui.admin.nav.tenants", to: "/tenants", icon: Building2 },
|
||||
{ label: "ui.admin.nav.relying_parties", to: "/relying-parties", icon: Rocket },
|
||||
{ label: "ui.admin.nav.users", to: "/users", icon: Users },
|
||||
{ label: "ui.admin.nav.api_keys", to: "/api-keys", icon: Key },
|
||||
{ label: "ui.admin.nav.tenant_groups", to: "/tenant-groups", icon: LayoutGrid },
|
||||
{ label: "ui.admin.nav.tenants", to: "/tenants", icon: Building2 },
|
||||
{ label: "ui.admin.nav.users", to: "/users", icon: Users }, { label: "ui.admin.nav.api_keys", to: "/api-keys", icon: Key },
|
||||
{ label: "ui.admin.nav.audit_logs", to: "/audit-logs", icon: NotebookTabs },
|
||||
{ label: "ui.admin.nav.auth_guard", to: "/auth", icon: KeyRound },
|
||||
];
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { ArrowLeft, Rocket } from "lucide-react";
|
||||
import { Link, Outlet, useLocation, useParams } from "react-router-dom";
|
||||
import { Badge } from "../../../components/ui/badge";
|
||||
import { fetchRelyingParty } from "../../../lib/adminApi";
|
||||
|
||||
function RPDetailPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const location = useLocation();
|
||||
|
||||
const rpQuery = useQuery({
|
||||
queryKey: ["relying-party", id],
|
||||
queryFn: () => fetchRelyingParty(id!),
|
||||
enabled: !!id,
|
||||
});
|
||||
|
||||
const isOwnersTab = location.pathname.endsWith("/owners");
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
<header className="flex flex-wrap items-start justify-between gap-4">
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center gap-2 text-sm text-[var(--color-muted)]">
|
||||
<Link to="/relying-parties" className="inline-flex items-center gap-2 hover:text-foreground">
|
||||
<ArrowLeft size={14} />
|
||||
Apps
|
||||
</Link>
|
||||
<span>/</span>
|
||||
<span className="text-foreground">Detail</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="p-2 bg-primary/10 rounded-lg">
|
||||
<Rocket size={24} className="text-primary" />
|
||||
</div>
|
||||
<h2 className="text-3xl font-semibold">
|
||||
{rpQuery.data?.relyingParty?.name ?? "Loading App..."}
|
||||
</h2>
|
||||
</div>
|
||||
<p className="text-sm text-[var(--color-muted)]">
|
||||
Client ID: <span className="font-mono">{id}</span>
|
||||
</p>
|
||||
</div>
|
||||
<Badge variant="muted">Admin only</Badge>
|
||||
</header>
|
||||
|
||||
{/* Tabs */}
|
||||
<div className="flex border-b border-border">
|
||||
<Link
|
||||
to={`/relying-parties/${id}`}
|
||||
className={`px-6 py-3 text-sm font-medium transition-colors ${
|
||||
!isOwnersTab
|
||||
? "border-b-2 border-primary text-primary"
|
||||
: "text-muted-foreground hover:text-foreground"
|
||||
}`}
|
||||
>
|
||||
기본 설정
|
||||
</Link>
|
||||
<Link
|
||||
to={`/relying-parties/${id}/owners`}
|
||||
className={`px-6 py-3 text-sm font-medium transition-colors ${
|
||||
isOwnersTab
|
||||
? "border-b-2 border-primary text-primary"
|
||||
: "text-muted-foreground hover:text-foreground"
|
||||
}`}
|
||||
>
|
||||
소유자 (권한 관리)
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="mt-6">
|
||||
<Outlet context={{ rp: rpQuery.data, refetch: rpQuery.refetch }} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default RPDetailPage;
|
||||
@@ -1,146 +0,0 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { Pencil, Plus, RefreshCw, Trash2, Rocket } from "lucide-react";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
import { Badge } from "../../../components/ui/badge";
|
||||
import { Button } from "../../../components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "../../../components/ui/card";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "../../../components/ui/table";
|
||||
import { deleteRelyingParty, fetchAllRelyingParties } from "../../../lib/adminApi";
|
||||
|
||||
function RPListPage() {
|
||||
const navigate = useNavigate();
|
||||
const query = useQuery({
|
||||
queryKey: ["relying-parties"],
|
||||
queryFn: () => fetchAllRelyingParties(),
|
||||
});
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: (id: string) => deleteRelyingParty(id),
|
||||
onSuccess: () => {
|
||||
query.refetch();
|
||||
},
|
||||
});
|
||||
|
||||
const items = query.data ?? [];
|
||||
|
||||
const handleDelete = (id: string, name: string) => {
|
||||
if (!window.confirm(`애플리케이션 "${name}"을 삭제할까요?`)) {
|
||||
return;
|
||||
}
|
||||
deleteMutation.mutate(id);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
<header className="flex flex-wrap items-start justify-between gap-4">
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center gap-2 text-sm text-[var(--color-muted)]">
|
||||
<span>Apps</span>
|
||||
<span>/</span>
|
||||
<span className="text-foreground">List</span>
|
||||
</div>
|
||||
<h2 className="text-3xl font-semibold">애플리케이션(RP) 목록</h2>
|
||||
<p className="text-sm text-[var(--color-muted)]">
|
||||
등록된 OAuth2 클라이언트(Relying Party) 목록입니다.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => query.refetch()}
|
||||
disabled={query.isFetching}
|
||||
>
|
||||
<RefreshCw size={16} />
|
||||
새로고침
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<Card className="bg-[var(--color-panel)]">
|
||||
<CardHeader className="flex flex-row items-center justify-between">
|
||||
<div>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Rocket size={20} className="text-primary" />
|
||||
Relying Party Registry
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
총 {items.length}개 앱
|
||||
</CardDescription>
|
||||
</div>
|
||||
<Badge variant="muted">Admin only</Badge>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>NAME</TableHead>
|
||||
<TableHead>CLIENT ID</TableHead>
|
||||
<TableHead>TENANT</TableHead>
|
||||
<TableHead className="text-right">ACTIONS</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{query.isLoading && (
|
||||
<TableRow>
|
||||
<TableCell colSpan={4}>로딩 중...</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{!query.isLoading && items.length === 0 && (
|
||||
<TableRow>
|
||||
<TableCell colSpan={4}>
|
||||
등록된 애플리케이션이 없습니다.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{items.map((rp) => (
|
||||
<TableRow key={rp.clientId}>
|
||||
<TableCell className="font-semibold">{rp.name}</TableCell>
|
||||
<TableCell className="text-xs font-mono">{rp.clientId}</TableCell>
|
||||
<TableCell>
|
||||
<Badge variant="outline">{rp.tenantId}</Badge>
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => navigate(`/relying-parties/${rp.clientId}`)}
|
||||
>
|
||||
<Pencil size={14} />
|
||||
관리
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => handleDelete(rp.clientId, rp.name)}
|
||||
disabled={deleteMutation.isPending}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
삭제
|
||||
</Button>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default RPListPage;
|
||||
@@ -1,201 +0,0 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { Plus, Trash2, ShieldCheck, Search, UserPlus } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useOutletContext, useParams } from "react-router-dom";
|
||||
import { Button } from "../../../components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "../../../components/ui/card";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "../../../components/ui/table";
|
||||
import { Input } from "../../../components/ui/input";
|
||||
import {
|
||||
fetchRPOwners,
|
||||
addRPOwner,
|
||||
removeRPOwner,
|
||||
fetchUsers
|
||||
} from "../../../lib/adminApi";
|
||||
|
||||
function RPOwnersTab() {
|
||||
const { id: clientId } = useParams<{ id: string }>();
|
||||
const queryClient = useQueryClient();
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
|
||||
if (!clientId) return null;
|
||||
|
||||
// 현재 소유자 목록
|
||||
const ownersQuery = useQuery({
|
||||
queryKey: ["rp-owners", clientId],
|
||||
queryFn: () => fetchRPOwners(clientId),
|
||||
enabled: !!clientId,
|
||||
});
|
||||
|
||||
// 전체 사용자 목록 (소유자 추가용)
|
||||
const usersQuery = useQuery({
|
||||
queryKey: ["users", { limit: 100, search: searchTerm }],
|
||||
queryFn: () => fetchUsers(100, 0, searchTerm),
|
||||
enabled: searchTerm.length > 1,
|
||||
});
|
||||
|
||||
const addMutation = useMutation({
|
||||
mutationFn: (subject: string) => addRPOwner(clientId, subject),
|
||||
onSuccess: () => {
|
||||
ownersQuery.refetch();
|
||||
setSearchTerm("");
|
||||
},
|
||||
});
|
||||
|
||||
const removeMutation = useMutation({
|
||||
mutationFn: (subject: string) => removeRPOwner(clientId, subject),
|
||||
onSuccess: () => {
|
||||
ownersQuery.refetch();
|
||||
},
|
||||
});
|
||||
|
||||
const handleAddOwner = (userId: string) => {
|
||||
addMutation.mutate(`User:${userId}`);
|
||||
};
|
||||
|
||||
const handleRemoveOwner = (subject: string, name?: string) => {
|
||||
if (window.confirm(`${name || subject}의 소유 권한을 회수할까요?`)) {
|
||||
removeMutation.mutate(subject);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="grid gap-6 lg:grid-cols-2">
|
||||
{/* 현재 앱 소유자 */}
|
||||
<Card className="bg-[var(--color-panel)]">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<ShieldCheck size={18} className="text-primary" />
|
||||
앱 소유자
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
이 애플리케이션의 설정을 관리하고 비밀번호를 회전시킬 수 있는 권한을 가진 사용자들입니다.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>이름/주체</TableHead>
|
||||
<TableHead>유형</TableHead>
|
||||
<TableHead className="text-right">회수</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{ownersQuery.data?.length === 0 && (
|
||||
<TableRow>
|
||||
<TableCell colSpan={3} className="text-center py-8 text-muted-foreground">
|
||||
등록된 소유자가 없습니다.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{ownersQuery.data?.map((owner) => (
|
||||
<TableRow key={owner.subject}>
|
||||
<TableCell>
|
||||
<div className="font-medium">{owner.name || owner.subject}</div>
|
||||
<div className="text-[10px] text-muted-foreground">{owner.email}</div>
|
||||
</TableCell>
|
||||
<TableCell className="text-xs">{owner.type}</TableCell>
|
||||
<TableCell className="text-right">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => handleRemoveOwner(owner.subject, owner.name)}
|
||||
disabled={removeMutation.isPending}
|
||||
>
|
||||
<Trash2 size={14} className="text-destructive" />
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* 사용자 검색 및 추가 */}
|
||||
<Card className="bg-[var(--color-panel)]">
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<UserPlus size={18} className="text-primary" />
|
||||
소유자 추가
|
||||
</CardTitle>
|
||||
</div>
|
||||
<CardDescription>
|
||||
소유자로 추가할 사용자를 검색하세요.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="relative">
|
||||
<Search className="absolute left-3 top-3 h-4 w-4 text-muted-foreground" />
|
||||
<Input
|
||||
placeholder="사용자 검색 (최소 2자)..."
|
||||
className="pl-10"
|
||||
value={searchTerm}
|
||||
onChange={e => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>사용자</TableHead>
|
||||
<TableHead className="text-right">추가</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{searchTerm.length < 2 && (
|
||||
<TableRow>
|
||||
<TableCell colSpan={2} className="text-center py-8 text-muted-foreground">
|
||||
사용자 이름을 입력하여 검색하세요.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{searchTerm.length >= 2 && usersQuery.data?.items.length === 0 && (
|
||||
<TableRow>
|
||||
<TableCell colSpan={2} className="text-center py-8 text-muted-foreground">
|
||||
검색 결과가 없습니다.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{usersQuery.data?.items.filter(u => !ownersQuery.data?.some(o => o.subject === `User:${u.id}`)).map((user) => (
|
||||
<TableRow key={user.id}>
|
||||
<TableCell>
|
||||
<div className="font-medium">{user.name}</div>
|
||||
<div className="text-[10px] text-muted-foreground">{user.email}</div>
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => handleAddOwner(user.id)}
|
||||
disabled={addMutation.isPending}
|
||||
>
|
||||
<Plus size={14} />
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default RPOwnersTab;
|
||||
@@ -1,82 +0,0 @@
|
||||
import { useOutletContext } from "react-router-dom";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "../../../components/ui/card";
|
||||
import { Input } from "../../../components/ui/input";
|
||||
import { Label } from "../../../components/ui/label";
|
||||
import { Badge } from "../../../components/ui/badge";
|
||||
import type { RelyingParty, HydraClientReq } from "../../../lib/adminApi";
|
||||
|
||||
function RPProfileTab() {
|
||||
const { rp } = useOutletContext<{
|
||||
rp: { relyingParty: RelyingParty; oauth2Config: HydraClientReq }
|
||||
}>();
|
||||
|
||||
if (!rp) return null;
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl space-y-6">
|
||||
<Card className="bg-[var(--color-panel)]">
|
||||
<CardHeader>
|
||||
<CardTitle>애플리케이션 정보</CardTitle>
|
||||
<CardDescription>
|
||||
OAuth2 클라이언트의 기본 정보 및 상태입니다.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label>App Name</Label>
|
||||
<Input value={rp.relyingParty.name} disabled className="bg-muted" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>Client ID</Label>
|
||||
<Input value={rp.relyingParty.clientId} disabled className="bg-muted font-mono text-xs" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>Tenant ID</Label>
|
||||
<div className="flex items-center gap-2">
|
||||
<Input value={rp.relyingParty.tenantId} disabled className="bg-muted flex-1" />
|
||||
<Badge>Owner Tenant</Badge>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>Scopes</Label>
|
||||
<div className="flex flex-wrap gap-2 p-3 border rounded-md bg-muted/30">
|
||||
{rp.oauth2Config.scope?.split(" ").map(s => (
|
||||
<Badge key={s} variant="outline">{s}</Badge>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="bg-[var(--color-panel)] border-primary/20">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-sm font-semibold">OAuth2 Endpoints</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
<div className="space-y-1">
|
||||
<Label className="text-[10px] uppercase text-muted-foreground">Authorization URL</Label>
|
||||
<code className="block p-2 bg-black/20 rounded text-xs break-all">
|
||||
https://sso.hmac.kr/oidc/oauth2/auth
|
||||
</code>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label className="text-[10px] uppercase text-muted-foreground">Token URL</Label>
|
||||
<code className="block p-2 bg-black/20 rounded text-xs break-all">
|
||||
https://sso.hmac.kr/oidc/oauth2/token
|
||||
</code>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default RPProfileTab;
|
||||
Reference in New Issue
Block a user