import { notFound } from "next/navigation"; import { ShieldCheck } from "lucide-react"; import { isSuperadmin, secretsAudit, type PlatformSecretRow } from "@peppa/core"; import { Hidden } from "@/components/cards"; import { Disclosure, Empty, Flash, Notice, PageHeader, Section } from "@/components/common"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import { Workspace } from "@/components/Workspace"; import { requireUser } from "@/lib/auth"; import { db } from "@/lib/db"; import { checkGiteaTokenAction, markSecretRotatedAction, reencryptSecretsAction, revokeClientTokensAction } from "../actions"; export const metadata = { title: "Секреты — Пеппа" }; type Params = { error?: string; reencrypted?: string; unreadable?: string; revoked?: string; gitea?: string }; const day = (d: Date | null) => (d ? d.toLocaleDateString("ru-RU") : "—"); function State({ r }: { r: PlatformSecretRow }) { if (r.set === null) return вне .env; if (!r.set) return r.optional ? не задан : не задан; return задан; } function Age({ r }: { r: PlatformSecretRow }) { if (r.ageDays === null) return возраст неизвестен; return r.stale ? {r.ageDays} дн. — пора ротировать : {r.ageDays} дн.; } /** Inline `code` in instruction steps. */ function Step({ text }: { text: string }) { return ( <> {text.split(/(`[^`]+`)/).map((part, i) => part.startsWith("`") ? ( {part.slice(1, -1)} ) : ( part ), )} ); } export default async function Secrets({ searchParams }: { searchParams: Promise }) { const user = await requireUser(); if (!(await isSuperadmin(db, user))) notFound(); const q = await searchParams; const a = await secretsAudit(db); const enc = a.encryption; return (
Секреты}> Ревизия секретов и доступов платформы: что задано, сколько лет каждому секрету, кто им пользуется и как его сменить. Значения здесь не показываются никогда. Раздел видят только суперадмины. {q.reencrypted !== undefined && ( Перешифровано: {q.reencrypted} {Number(q.unreadable) > 0 ? ` · не читается ни одним ключом: ${q.unreadable}` : ""} )} {q.revoked !== undefined && Отозвано токенов: {q.revoked}} {q.gitea && {q.gitea.startsWith("ok:") ? `GITEA_TOKEN принадлежит ${q.gitea.slice(3)}, админских прав нет` : `GITEA_TOKEN: ${q.gitea}`}}
{!enc.configured ? PEPPA_SECRET не задан : enc.rotating ? идёт смена ключа : один ключ} на старом ключе: {enc.previous} · не читается: {enc.unreadable}
    {enc.columns.filter((c) => c.total).map((c) => (
  • {c.table}.{c.column}: {c.total} · текущий {c.current} · старый {c.previous} · не читается {c.unreadable}
  • ))}
{a.platform.map((r) => (
{r.name} {r.how === "peppa" ? "ротирует Пеппа" : "вручную"}

{r.label}

Использует: {r.usedBy} {r.rotatedAt ? ` · последняя ротация ${day(r.rotatedAt)}${r.rotatedBy ? ` (${r.rotatedBy})` : ""}` : ""}

    {r.steps.map((s, i) => (
  1. ))}
{r.how === "external" && (
)} {r.name === "GITEA_TOKEN" && (
)}
))}
{a.oauth.length === 0 ? ( Живых MCP-токенов нет. ) : ( a.oauth.map((c) => ( {c.name} токенов {c.liveTokens} · людей {c.users} · старейший {day(c.oldestAt)} · использован {day(c.lastUsedAt)} {c.beforeKeyRotation ? ` · выданы до смены ключа: ${c.beforeKeyRotation}` : ""}
)) )}

Пользователи отзывают свои подключения сами в «Настройках»; OAuth Gitea у пользователей: {a.gitea.usersWithToken} (истекли {a.gitea.expired}) — обновляются при входе.

{a.subscriptions.length === 0 ? ( Подписок нет. ) : (
    {a.subscriptions.map((s) => (
  • {s.name} {s.provider} · {s.status} · сессий {s.liveSessions} · пулы: {s.pools.join(", ") || "—"} {s.stale ? {s.ageDays} дн. — перевыпустить : {s.ageDays} дн.}
  • ))}
)}

Перевыпуск — в «Подписках»: «Переподключить» запускает новый вход, старый токен Claude отзывается в claude.ai → Settings → Claude Code.

{a.projects.length === 0 ? ( Ни в одном проекте секретов нет. ) : (
    {a.projects.map((p) => (
  • {p.key} секретов {p.secrets} · старейший {day(p.oldestAt)} · выдан агенту {day(p.lastUsedAt)}
  • ))}
)}
); }