1
0
forked from baron/baron-sso

consent 철회 확인 모달 및 상태 필터 UI 추가

This commit is contained in:
2026-02-26 12:39:56 +09:00
parent 2b20a85bc5
commit 099a8c768c
4 changed files with 96 additions and 48 deletions

View File

@@ -33,6 +33,8 @@ function ClientConsentsPage() {
const clientId = params.id ?? ""; const clientId = params.id ?? "";
const [subjectInput, setSubjectInput] = useState(""); const [subjectInput, setSubjectInput] = useState("");
const [subject, setSubject] = useState(""); const [subject, setSubject] = useState("");
const [statusFilter, setStatusFilter] = useState("all");
const { data: clientData } = useQuery({ const { data: clientData } = useQuery({
queryKey: ["client", clientId], queryKey: ["client", clientId],
queryFn: () => fetchClient(clientId), queryFn: () => fetchClient(clientId),
@@ -44,9 +46,9 @@ function ClientConsentsPage() {
error, error,
refetch, refetch,
} = useQuery({ } = useQuery({
queryKey: ["consents", clientId, subject], queryKey: ["consents", clientId, subject, statusFilter],
queryFn: () => fetchConsents(subject, clientId), queryFn: () => fetchConsents(subject, clientId, statusFilter),
enabled: clientId.length > 0, // Removed subject.length > 0 check enabled: clientId.length > 0,
}); });
const revokeMutation = useMutation({ const revokeMutation = useMutation({
mutationFn: (payload: { subject: string }) => mutationFn: (payload: { subject: string }) =>
@@ -56,6 +58,19 @@ function ClientConsentsPage() {
}, },
}); });
const handleRevoke = (sub: string) => {
if (
window.confirm(
t(
"msg.dev.clients.consents.revoke_confirm",
"정말로 이 사용자의 권한을 철회하시겠습니까? 철회 시 사용자는 다음 접속 시 다시 동의해야 합니다.",
),
)
) {
revokeMutation.mutate({ subject: sub });
}
};
const rows = consentsData?.items ?? []; const rows = consentsData?.items ?? [];
return ( return (
@@ -150,14 +165,18 @@ function ClientConsentsPage() {
<span className="text-xs font-bold uppercase tracking-wider text-muted-foreground"> <span className="text-xs font-bold uppercase tracking-wider text-muted-foreground">
{t("ui.dev.clients.consents.status_label", "Status:")} {t("ui.dev.clients.consents.status_label", "Status:")}
</span> </span>
<select className="h-10 rounded-lg border border-input bg-background px-3 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30"> <select
<option> className="h-10 rounded-lg border border-input bg-background px-3 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30"
value={statusFilter}
onChange={(e) => setStatusFilter(e.target.value)}
>
<option value="all">
{t("ui.dev.clients.consents.status_all", "All Statuses")} {t("ui.dev.clients.consents.status_all", "All Statuses")}
</option> </option>
<option selected> <option value="active">
{t("ui.common.status.active", "Active")} {t("ui.common.status.active", "Active")}
</option> </option>
<option> <option value="revoked">
{t("ui.dev.clients.consents.status_revoked", "Revoked")} {t("ui.dev.clients.consents.status_revoked", "Revoked")}
</option> </option>
</select> </select>
@@ -226,7 +245,7 @@ function ClientConsentsPage() {
<TableHead> <TableHead>
{t( {t(
"ui.dev.clients.consents.table.last_auth", "ui.dev.clients.consents.table.last_auth",
"Last Authenticated", "Last Authenticated / Revoked",
)} )}
</TableHead> </TableHead>
<TableHead className="text-right"> <TableHead className="text-right">
@@ -243,7 +262,10 @@ function ClientConsentsPage() {
</TableRow> </TableRow>
) : ( ) : (
rows.map((row) => ( rows.map((row) => (
<TableRow key={`${row.subject}-${row.clientId}`}> <TableRow
key={`${row.subject}-${row.clientId}`}
className={row.status === "revoked" ? "opacity-60" : ""}
>
<TableCell> <TableCell>
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-primary/10 text-xs font-bold text-primary"> <div className="flex h-8 w-8 items-center justify-center rounded-full bg-primary/10 text-xs font-bold text-primary">
@@ -273,9 +295,15 @@ function ClientConsentsPage() {
</div> </div>
</TableCell> </TableCell>
<TableCell> <TableCell>
<Badge variant="success"> {row.status === "active" ? (
{t("ui.common.status.active", "Active")} <Badge variant="success">
</Badge> {t("ui.common.status.active", "Active")}
</Badge>
) : (
<Badge variant="warning">
{t("ui.dev.clients.consents.status_revoked", "Revoked")}
</Badge>
)}
</TableCell> </TableCell>
<TableCell> <TableCell>
<div className="flex flex-wrap gap-1"> <div className="flex flex-wrap gap-1">
@@ -294,20 +322,28 @@ function ClientConsentsPage() {
{new Date(row.createdAt).toLocaleString()} {new Date(row.createdAt).toLocaleString()}
</TableCell> </TableCell>
<TableCell className="text-sm text-muted-foreground"> <TableCell className="text-sm text-muted-foreground">
{row.authenticatedAt {row.status === "revoked" && row.deletedAt ? (
? new Date(row.authenticatedAt).toLocaleString() <span className="text-destructive font-medium">
: "-"} {t("ui.dev.clients.consents.revoked_at", "Revoked: ")}
{new Date(row.deletedAt).toLocaleString()}
</span>
) : row.authenticatedAt ? (
new Date(row.authenticatedAt).toLocaleString()
) : (
"-"
)}
</TableCell> </TableCell>
<TableCell className="text-right"> <TableCell className="text-right">
<Button {row.status === "active" && (
variant="ghost" <Button
className="text-destructive" variant="ghost"
onClick={() => className="text-destructive hover:bg-destructive/10"
revokeMutation.mutate({ subject: row.subject }) onClick={() => handleRevoke(row.subject)}
} disabled={revokeMutation.isPending}
> >
{t("ui.dev.clients.consents.revoke", "Revoke")} {t("ui.dev.clients.consents.revoke", "Revoke")}
</Button> </Button>
)}
</TableCell> </TableCell>
</TableRow> </TableRow>
)) ))
@@ -349,7 +385,9 @@ function ClientConsentsPage() {
"Active Grants", "Active Grants",
)} )}
</p> </p>
<CardTitle className="text-2xl font-black">{rows.length}</CardTitle> <CardTitle className="text-2xl font-black">
{rows.filter((r) => r.status === "active").length}
</CardTitle>
</CardHeader> </CardHeader>
</Card> </Card>
<Card className="glass-panel"> <Card className="glass-panel">

View File

@@ -156,7 +156,7 @@ const CreateIdpModal = ({
disabled={ disabled={
mutation.isPending || mutation.isPending ||
formData.display_name.trim() === "" || formData.display_name.trim() === "" ||
formData.issuer_url.trim() === "" (formData.issuer_url?.trim() ?? "") === ""
} }
> >
{mutation.isPending ? ( {mutation.isPending ? (

View File

@@ -57,6 +57,8 @@ export type ConsentSummary = {
grantedScopes: string[]; grantedScopes: string[];
authenticatedAt?: string; authenticatedAt?: string;
createdAt: string; createdAt: string;
deletedAt?: string;
status: "active" | "revoked";
tenantId?: string; tenantId?: string;
tenantName?: string; tenantName?: string;
}; };
@@ -148,11 +150,18 @@ export async function deleteClient(clientId: string) {
await apiClient.delete(`/dev/clients/${clientId}`); await apiClient.delete(`/dev/clients/${clientId}`);
} }
export async function fetchConsents(subject: string, clientId?: string) { export async function fetchConsents(
subject: string,
clientId?: string,
status?: string,
) {
const params: Record<string, string> = { subject }; const params: Record<string, string> = { subject };
if (clientId) { if (clientId) {
params.client_id = clientId; params.client_id = clientId;
} }
if (status && status !== "all") {
params.status = status;
}
const { data } = await apiClient.get<ConsentListResponse>("/dev/consents", { const { data } = await apiClient.get<ConsentListResponse>("/dev/consents", {
params, params,
}); });

View File

@@ -956,36 +956,37 @@ admin_session = "관리자 세션"
tenant_selected = "테넌트: 선택됨" tenant_selected = "테넌트: 선택됨"
[ui.dev.clients.consents] [ui.dev.clients.consents]
export_csv = "Export CSV" export_csv = "CSV 내보내기"
revoke = "Revoke" revoke = "권한 철회"
revoked_at = "철회일: "
search_placeholder = "사용자 ID, 이름, 이메일로 검색" search_placeholder = "사용자 ID, 이름, 이메일로 검색"
status_all = "All Statuses" status_all = "모든 상태"
status_label = "Status:" status_label = "상태:"
status_revoked = "Revoked" status_revoked = "철회됨"
subject = "Subject" subject = "사용자 ID"
title = "User Consent Grants" title = "사용자 동의 권한 관리"
[ui.dev.clients.consents.breadcrumb] [ui.dev.clients.consents.breadcrumb]
clients = "Clients" clients = "애플리케이션"
current = "User Consent Grants" current = "사용자 동의 권한"
home = "Home" home = ""
[ui.dev.clients.consents.filters] [ui.dev.clients.consents.filters]
advanced = "Advanced Filters" advanced = "상세 필터"
[ui.dev.clients.consents.stats] [ui.dev.clients.consents.stats]
active_grants = "Active Grants" active_grants = "활성 권한"
avg_scopes = "Avg. Scopes per User" avg_scopes = "사용자당 평균 권한 수"
total_scopes = "Total Scopes Issued" total_scopes = "전체 부여된 권한 수"
[ui.dev.clients.consents.table] [ui.dev.clients.consents.table]
action = "Action" action = "작업"
first_granted = "First Granted" first_granted = "최초 동의"
last_auth = "Last Authenticated" last_auth = "최근 인증 / 철회"
scopes = "Granted Scopes" scopes = "부여된 권한 (Scopes)"
status = "Status" status = "상태"
tenant = "Tenant" tenant = "테넌트"
user = "User" user = "사용자"
[ui.dev.clients.details] [ui.dev.clients.details]