366 lines
21 KiB
TypeScript
366 lines
21 KiB
TypeScript
// glossary-ignore-file: ревизию секретов читает только суперадмин
|
||
// PEP-19: audit of the platform's secrets and accesses, and rotation where Peppa can do it
|
||
// itself (PEPPA_SECRET two-key transition + re-encryption, MCP tokens). External secrets get
|
||
// step-by-step instructions and a "rotated" mark that restarts their age. Values never leave.
|
||
import { m as tr } from "@peppa/shared/i18n";
|
||
import { randomBytes } from "node:crypto";
|
||
import { connections, oauthClients, oauthTokens, projects, projectSecrets, sessions, subscriptionPoolMembers, subscriptionPools, subscriptions, users, type Db } from "@peppa/db";
|
||
import { and, eq, gt, isNotNull, isNull, notInArray, sql } from "drizzle-orm";
|
||
import { logEvent } from "./audit.ts";
|
||
import { encrypt, decrypt, encryptedWith, rotatingSecret } from "./crypto.ts";
|
||
import { upgradeConnectionKeys } from "./connections.ts";
|
||
import { PeppaError } from "./errors.ts";
|
||
import { GiteaClient } from "./gitea.ts";
|
||
import { FINISHED_SESSION_STATUSES } from "./sessions.ts";
|
||
import { getSetting, setSetting } from "./settings.ts";
|
||
|
||
const DAY = 86_400_000;
|
||
/** A secret older than this is flagged «пора ротировать». */
|
||
export const SECRET_STALE_DAYS = 180;
|
||
|
||
export interface PlatformSecretDef {
|
||
name: string;
|
||
label: string;
|
||
usedBy: string;
|
||
/** peppa — Peppa rotates it itself (with the steps); external — a person does it elsewhere. */
|
||
how: "peppa" | "external";
|
||
/** Not an env variable (e.g. the peppa-bot password lives only in Gitea). */
|
||
envless?: boolean;
|
||
optional?: boolean;
|
||
steps: string[];
|
||
}
|
||
|
||
const RESTART = tr("Перезапустить сервисы: `launchctl kickstart -k gui/$(id -u)/quest.telecom.peppa.{web,bot,watchdog}`.");
|
||
|
||
export const PLATFORM_SECRETS: PlatformSecretDef[] = [
|
||
{
|
||
name: "PEPPA_SECRET",
|
||
label: tr("Ключ шифрования и подписи FORGE"),
|
||
usedBy: tr("шифрование токенов (OAuth Gitea, подписки, секреты проектов), cookie входа, хэши MCP-токенов, секреты вебхуков и CI проектов"),
|
||
how: "peppa",
|
||
steps: [
|
||
"`peppa db backup`.",
|
||
tr("`peppa secrets new-key` — новый ключ."),
|
||
tr("В `.env`: старое значение `PEPPA_SECRET` перенести в `PEPPA_SECRET_PREVIOUS`, новое — в `PEPPA_SECRET`."),
|
||
RESTART,
|
||
tr("`peppa secrets reencrypt` — всё зашифрованное переходит на новый ключ; повторять, пока «на старом ключе: 0»."),
|
||
tr("`peppa ci connect <KEY>` для каждого проекта с CI — секрет вебхука Gitea и Actions-секрет `PEPPA_CI_SECRET` нового ключа."),
|
||
tr("Через 30 дней (срок refresh-токенов MCP) или когда в ревизии «выданы до смены ключа: 0» — удалить `PEPPA_SECRET_PREVIOUS` и перезапустить сервисы. Ссылки входа и потоки eGov, начатые до смены, нужно начать заново."),
|
||
],
|
||
},
|
||
{
|
||
name: "GITEA_TOKEN",
|
||
label: tr("Токен peppa-bot в Gitea"),
|
||
usedBy: tr("создание проектов и репо, соавторы, CI (регистрация раннера, вебхуки, статусы), комментарии бота, импорт issues"),
|
||
how: "external",
|
||
steps: [
|
||
tr("Войти в Gitea под peppa-bot → Настройки → Приложения → «Создать токен»."),
|
||
tr("Права — только нужные: `write:repository`, `write:issue`, `write:organization`, `write:user` (регистрация раннера CI), `read:misc`. Без `sudo` и админских; peppa-bot не должен быть администратором Gitea."),
|
||
tr("Новый токен — в `GITEA_TOKEN` в `.env`, {restart}", { restart: RESTART }),
|
||
tr("Проверить: «Проверить токен Gitea» на этой странице (логин peppa-bot, не админ) и `peppa status`."),
|
||
tr("Удалить старый токен в Gitea, отметить ротацию: `peppa secrets rotated GITEA_TOKEN`."),
|
||
],
|
||
},
|
||
{
|
||
name: "GITEA_BOT_PASSWORD",
|
||
label: tr("Пароль учётной записи peppa-bot в Gitea"),
|
||
usedBy: tr("только ручной вход в Gitea под peppa-bot (FORGE его не хранит)"),
|
||
how: "external",
|
||
envless: true,
|
||
steps: [
|
||
tr("Gitea → Настройки → Аккаунт под peppa-bot (или админом: Администрирование → Пользователи → peppa-bot) — сменить пароль на случайный, сохранить в менеджере паролей."),
|
||
tr("Включить 2FA для peppa-bot, если ею пользуются люди."),
|
||
tr("Отметить: `peppa secrets rotated GITEA_BOT_PASSWORD`."),
|
||
],
|
||
},
|
||
{
|
||
name: "TELEGRAM_BOT_TOKEN",
|
||
label: tr("Токен Telegram-бота"),
|
||
usedBy: tr("бот (вопросы PM, уведомления), алерты мониторинга от вачдога"),
|
||
how: "external",
|
||
steps: [
|
||
tr("@BotFather → /mybots → бот FORGE → API Token → «Revoke current token» — старый токен сразу перестаёт работать."),
|
||
tr("Новый токен — в `TELEGRAM_BOT_TOKEN` в `.env`, {restart}", { restart: RESTART }),
|
||
tr("Проверить: `peppa status` (бот на связи), `/status` в боте."),
|
||
tr("Отметить: `peppa secrets rotated TELEGRAM_BOT_TOKEN`."),
|
||
],
|
||
},
|
||
{
|
||
name: "GITEA_OAUTH_CLIENT_SECRET",
|
||
label: tr("Секрет OAuth-приложения FORGE в Gitea"),
|
||
usedBy: tr("вход в веб через Gitea и обновление токенов пользователей"),
|
||
how: "external",
|
||
steps: [
|
||
tr("Gitea → Настройки (владелец приложения) → Приложения → OAuth2 «Peppa» → «Сгенерировать новый секрет»."),
|
||
tr("Новый секрет — в `GITEA_OAUTH_CLIENT_SECRET`, {restart}", { restart: RESTART }),
|
||
tr("Пользователи, чей токен Gitea истечёт, войдут заново автоматически при следующем входе."),
|
||
tr("Отметить: `peppa secrets rotated GITEA_OAUTH_CLIENT_SECRET`."),
|
||
],
|
||
},
|
||
{
|
||
name: "BUGSINK_TOKEN",
|
||
label: tr("API-токен Bugsink"),
|
||
usedBy: tr("подключение проектов к Bugsink и опрос issues вачдогом"),
|
||
how: "external",
|
||
optional: true,
|
||
steps: [
|
||
tr("`docker exec peppa-bugsink bugsink-manage create_auth_token` — новый токен; старый удалить в админке Bugsink (Auth tokens)."),
|
||
tr("В `BUGSINK_TOKEN`, {restart}", { restart: RESTART }),
|
||
tr("Отметить: `peppa secrets rotated BUGSINK_TOKEN`."),
|
||
],
|
||
},
|
||
{
|
||
name: "BUGSINK_SECRET_KEY",
|
||
label: tr("SECRET_KEY Django в Bugsink"),
|
||
usedBy: tr("сессии админки Bugsink"),
|
||
how: "external",
|
||
optional: true,
|
||
steps: [tr("Новое случайное значение в `BUGSINK_SECRET_KEY`, затем `scripts/infra-up.sh bugsink` (входы в админку Bugsink сбросятся)."), tr("Отметить: `peppa secrets rotated BUGSINK_SECRET_KEY`.")],
|
||
},
|
||
{
|
||
name: "BUGSINK_DB_PASSWORD",
|
||
label: tr("Пароль базы Bugsink в Postgres"),
|
||
usedBy: tr("контейнер Bugsink"),
|
||
how: "external",
|
||
optional: true,
|
||
steps: [
|
||
tr("`docker exec peppa-postgres psql -U postgres -c \"ALTER USER bugsink PASSWORD '<новый>'\"`."),
|
||
tr("Новое значение в `BUGSINK_DB_PASSWORD`, затем `scripts/infra-up.sh bugsink`."),
|
||
tr("Отметить: `peppa secrets rotated BUGSINK_DB_PASSWORD`."),
|
||
],
|
||
},
|
||
{
|
||
name: "BUGSINK_ADMIN_PASSWORD",
|
||
label: tr("Пароль админа Bugsink"),
|
||
usedBy: tr("вход в веб-интерфейс Bugsink"),
|
||
how: "external",
|
||
optional: true,
|
||
steps: [tr("Bugsink → профиль админа → сменить пароль; новое значение в `BUGSINK_ADMIN_PASSWORD` (для пересоздания контейнера)."), tr("Отметить: `peppa secrets rotated BUGSINK_ADMIN_PASSWORD`.")],
|
||
},
|
||
{
|
||
name: "PEPPA_TRANSCRIBE_KEY",
|
||
label: tr("Ключ распознавания голоса"),
|
||
usedBy: tr("голосовые сообщения боту (стори из сообщения)"),
|
||
how: "external",
|
||
optional: true,
|
||
steps: [tr("Выпустить новый ключ у провайдера (OpenAI-совместимый API), старый отозвать."), tr("В `PEPPA_TRANSCRIBE_KEY`, перезапустить бота."), tr("Отметить: `peppa secrets rotated PEPPA_TRANSCRIBE_KEY`.")],
|
||
},
|
||
];
|
||
|
||
const rotatedKey = (name: string) => `secrets.rotated:${name}`;
|
||
type RotationMark = { at: number; by: string | null };
|
||
|
||
export interface PlatformSecretRow extends PlatformSecretDef {
|
||
/** null — not an env variable, unknown. */
|
||
set: boolean | null;
|
||
rotatedAt: Date | null;
|
||
rotatedBy: string | null;
|
||
ageDays: number | null;
|
||
stale: boolean;
|
||
}
|
||
|
||
export interface EncryptedColumn {
|
||
table: string;
|
||
column: string;
|
||
total: number;
|
||
current: number;
|
||
previous: number;
|
||
unreadable: number;
|
||
}
|
||
|
||
export interface SecretsAudit {
|
||
generatedAt: Date;
|
||
platform: PlatformSecretRow[];
|
||
encryption: { configured: boolean; rotating: boolean; columns: EncryptedColumn[]; previous: number; unreadable: number };
|
||
gitea: { usersWithToken: number; expired: number };
|
||
oauth: Array<{ clientId: string; name: string; liveTokens: number; users: number; oldestAt: Date | null; lastUsedAt: Date | null; beforeKeyRotation: number }>;
|
||
subscriptions: Array<{ id: number; name: string; provider: string; status: string; createdAt: Date; ageDays: number; stale: boolean; liveSessions: number; pools: string[] }>;
|
||
projects: Array<{ projectId: number; key: string; secrets: number; oldestAt: Date | null; lastUsedAt: Date | null }>;
|
||
}
|
||
|
||
function envSet(name: string, env: NodeJS.ProcessEnv): boolean {
|
||
return !!env[name]?.trim();
|
||
}
|
||
|
||
/** Each encrypted column of the database: [table, column, select of {id, enc}]. */
|
||
function encryptedColumns(db: Db) {
|
||
return [
|
||
{ table: "users", column: "access_token_enc", rows: () => db.select({ id: users.id, enc: users.accessTokenEnc }).from(users).where(isNotNull(users.accessTokenEnc)), set: (id: number, enc: string) => db.update(users).set({ accessTokenEnc: enc }).where(eq(users.id, id)) },
|
||
{ table: "users", column: "refresh_token_enc", rows: () => db.select({ id: users.id, enc: users.refreshTokenEnc }).from(users).where(isNotNull(users.refreshTokenEnc)), set: (id: number, enc: string) => db.update(users).set({ refreshTokenEnc: enc }).where(eq(users.id, id)) },
|
||
{ table: "users", column: "claude_token_enc", rows: () => db.select({ id: users.id, enc: users.claudeTokenEnc }).from(users).where(isNotNull(users.claudeTokenEnc)), set: (id: number, enc: string) => db.update(users).set({ claudeTokenEnc: enc }).where(eq(users.id, id)) },
|
||
{ table: "users", column: "telegram_bot_token_enc", rows: () => db.select({ id: users.id, enc: users.telegramBotTokenEnc }).from(users).where(isNotNull(users.telegramBotTokenEnc)), set: (id: number, enc: string) => db.update(users).set({ telegramBotTokenEnc: enc }).where(eq(users.id, id)) },
|
||
{ table: "subscriptions", column: "secret_enc", rows: () => db.select({ id: subscriptions.id, enc: subscriptions.secretEnc }).from(subscriptions).where(isNotNull(subscriptions.secretEnc)), set: (id: number, enc: string) => db.update(subscriptions).set({ secretEnc: enc }).where(eq(subscriptions.id, id)) },
|
||
{ table: "project_secrets", column: "value_enc", rows: () => db.select({ id: projectSecrets.id, enc: projectSecrets.valueEnc }).from(projectSecrets), set: (id: number, enc: string) => db.update(projectSecrets).set({ valueEnc: enc }).where(eq(projectSecrets.id, id)) },
|
||
// PEP-254: Access Hub keys sit under their own data key; PEPPA_SECRET guards only the data
|
||
// keys. Old rows not yet moved by `upgradeConnectionKeys` still hold the key itself.
|
||
{ table: "connections", column: "dek_enc", rows: () => db.select({ id: connections.id, enc: connections.dekEnc }).from(connections).where(isNotNull(connections.dekEnc)), set: (id: number, enc: string) => db.update(connections).set({ dekEnc: enc }).where(eq(connections.id, id)) },
|
||
{ table: "connections", column: "secret_enc", rows: () => db.select({ id: connections.id, enc: connections.secretEnc }).from(connections).where(and(isNotNull(connections.secretEnc), isNull(connections.dekEnc))), set: (id: number, enc: string) => db.update(connections).set({ secretEnc: enc }).where(and(eq(connections.id, id), isNull(connections.dekEnc))) },
|
||
];
|
||
}
|
||
|
||
async function encryptionState(db: Db): Promise<SecretsAudit["encryption"]> {
|
||
const configured = envSet("PEPPA_SECRET", process.env);
|
||
const columns: EncryptedColumn[] = [];
|
||
for (const c of encryptedColumns(db)) {
|
||
const rows = await c.rows();
|
||
const col: EncryptedColumn = { table: c.table, column: c.column, total: rows.length, current: 0, previous: 0, unreadable: 0 };
|
||
for (const r of rows) {
|
||
const k = configured ? encryptedWith(r.enc!) : "unknown";
|
||
if (k === "current") col.current++;
|
||
else if (k === "previous") col.previous++;
|
||
else col.unreadable++;
|
||
}
|
||
columns.push(col);
|
||
}
|
||
return {
|
||
configured,
|
||
rotating: configured && rotatingSecret(),
|
||
columns,
|
||
previous: columns.reduce((n, c) => n + c.previous, 0),
|
||
unreadable: columns.reduce((n, c) => n + c.unreadable, 0),
|
||
};
|
||
}
|
||
|
||
/** The full report for `/secrets` and `peppa secrets audit`. Values never appear in it. */
|
||
export async function secretsAudit(db: Db, now = new Date(), env: NodeJS.ProcessEnv = process.env): Promise<SecretsAudit> {
|
||
const platform: PlatformSecretRow[] = [];
|
||
for (const d of PLATFORM_SECRETS) {
|
||
const mark = await getSetting<RotationMark>(db, rotatedKey(d.name));
|
||
const ageDays = mark ? Math.floor((now.getTime() - mark.at) / DAY) : null;
|
||
platform.push({ ...d, set: d.envless ? null : envSet(d.name, env), rotatedAt: mark ? new Date(mark.at) : null, rotatedBy: mark?.by ?? null, ageDays, stale: ageDays !== null && ageDays >= SECRET_STALE_DAYS });
|
||
}
|
||
|
||
const giteaRows = await db.select({ exp: users.tokenExpiresAt }).from(users).where(isNotNull(users.accessTokenEnc));
|
||
const gitea = { usersWithToken: giteaRows.length, expired: giteaRows.filter((r) => r.exp && r.exp < now).length };
|
||
|
||
const keyMark = await getSetting<RotationMark>(db, rotatedKey("PEPPA_SECRET"));
|
||
const live = await db
|
||
.select({ clientId: oauthClients.id, name: oauthClients.name, userId: oauthTokens.userId, createdAt: oauthTokens.createdAt, lastUsedAt: oauthTokens.lastUsedAt })
|
||
.from(oauthTokens)
|
||
.innerJoin(oauthClients, eq(oauthClients.id, oauthTokens.clientId))
|
||
.where(and(isNull(oauthTokens.revokedAt), gt(oauthTokens.expiresAt, now)));
|
||
const byClient = new Map<string, SecretsAudit["oauth"][number] & { userIds: Set<number> }>();
|
||
for (const t of live) {
|
||
let c = byClient.get(t.clientId);
|
||
if (!c) byClient.set(t.clientId, (c = { clientId: t.clientId, name: t.name, liveTokens: 0, users: 0, oldestAt: null, lastUsedAt: null, beforeKeyRotation: 0, userIds: new Set() }));
|
||
c.liveTokens++;
|
||
c.userIds.add(t.userId);
|
||
if (!c.oldestAt || t.createdAt < c.oldestAt) c.oldestAt = t.createdAt;
|
||
if (t.lastUsedAt && (!c.lastUsedAt || t.lastUsedAt > c.lastUsedAt)) c.lastUsedAt = t.lastUsedAt;
|
||
if (keyMark && t.createdAt.getTime() < keyMark.at) c.beforeKeyRotation++;
|
||
}
|
||
const oauth = [...byClient.values()].map(({ userIds, ...c }) => ({ ...c, users: userIds.size })).sort((a, b) => b.liveTokens - a.liveTokens);
|
||
|
||
const subs = await db.select().from(subscriptions).orderBy(subscriptions.id);
|
||
const liveSessions = await db
|
||
.select({ id: sessions.subscriptionId, n: sql<number>`count(*)` })
|
||
.from(sessions)
|
||
.where(and(isNotNull(sessions.subscriptionId), notInArray(sessions.status, FINISHED_SESSION_STATUSES)))
|
||
.groupBy(sessions.subscriptionId);
|
||
const pools = await db.select({ sub: subscriptionPoolMembers.subscriptionId, name: subscriptionPools.name }).from(subscriptionPoolMembers).innerJoin(subscriptionPools, eq(subscriptionPools.id, subscriptionPoolMembers.poolId));
|
||
const subscriptionsRows = subs.map((s) => {
|
||
const ageDays = Math.floor((now.getTime() - (s.activatedAt ?? s.createdAt).getTime()) / DAY);
|
||
return {
|
||
id: s.id,
|
||
name: s.name,
|
||
provider: s.provider,
|
||
status: s.status,
|
||
createdAt: s.createdAt,
|
||
ageDays,
|
||
stale: ageDays >= SECRET_STALE_DAYS,
|
||
liveSessions: Number(liveSessions.find((l) => l.id === s.id)?.n ?? 0),
|
||
pools: pools.filter((p) => p.sub === s.id).map((p) => p.name),
|
||
};
|
||
});
|
||
|
||
const ps = await db
|
||
.select({ projectId: projects.id, key: projects.key, n: sql<number>`count(*)`, oldest: sql<number | null>`min(${projectSecrets.updatedAt})`, used: sql<number | null>`max(${projectSecrets.lastUsedAt})` })
|
||
.from(projectSecrets)
|
||
.innerJoin(projects, eq(projects.id, projectSecrets.projectId))
|
||
.groupBy(projects.id)
|
||
.orderBy(projects.key);
|
||
|
||
return {
|
||
generatedAt: now,
|
||
platform,
|
||
encryption: await encryptionState(db),
|
||
gitea,
|
||
oauth,
|
||
subscriptions: subscriptionsRows,
|
||
projects: ps.map((p) => ({ projectId: p.projectId, key: p.key, secrets: Number(p.n), oldestAt: p.oldest ? new Date(Number(p.oldest)) : null, lastUsedAt: p.used ? new Date(Number(p.used)) : null })),
|
||
};
|
||
}
|
||
|
||
/** The platform project (PEP) gets platform-level journal events, if it exists. */
|
||
async function platformProjectId(db: Db): Promise<number | null> {
|
||
const [p] = await db.select({ id: projects.id }).from(projects).where(eq(projects.key, process.env.PEPPA_PLATFORM_KEY || "PEP"));
|
||
return p?.id ?? null;
|
||
}
|
||
|
||
/** Records that a platform secret was rotated (its age restarts). */
|
||
export async function markSecretRotated(db: Db, name: string, by: string | null, now = new Date()): Promise<void> {
|
||
if (!PLATFORM_SECRETS.some((d) => d.name === name)) throw new PeppaError(tr("Неизвестный секрет платформы: {name}", { name }));
|
||
await setSetting(db, rotatedKey(name), { at: now.getTime(), by } satisfies RotationMark);
|
||
const pid = await platformProjectId(db);
|
||
if (pid) await logEvent(db, { projectId: pid, type: "secret_rotated", payload: { name, by } });
|
||
}
|
||
|
||
export interface ReencryptResult {
|
||
reencrypted: number;
|
||
alreadyCurrent: number;
|
||
unreadable: Array<{ table: string; column: string; id: number }>;
|
||
}
|
||
|
||
/**
|
||
* Re-encrypts every value that only PEPPA_SECRET_PREVIOUS opens with the current key.
|
||
* Unreadable values (neither key) are left untouched and reported.
|
||
*/
|
||
export async function reencryptAll(db: Db, by: string | null = null): Promise<ReencryptResult> {
|
||
if (!envSet("PEPPA_SECRET", process.env)) throw new PeppaError(tr("PEPPA_SECRET не задан"));
|
||
const out: ReencryptResult = { reencrypted: 0, alreadyCurrent: 0, unreadable: [] };
|
||
// PEP-254: old Access Hub rows first get a data key of their own (then only it is re-encrypted).
|
||
await upgradeConnectionKeys(db);
|
||
for (const c of encryptedColumns(db)) {
|
||
for (const r of await c.rows()) {
|
||
const k = encryptedWith(r.enc!);
|
||
if (k === "current") out.alreadyCurrent++;
|
||
else if (k === "unknown") out.unreadable.push({ table: c.table, column: c.column, id: r.id });
|
||
else {
|
||
await c.set(r.id, encrypt(decrypt(r.enc!)));
|
||
out.reencrypted++;
|
||
}
|
||
}
|
||
}
|
||
// The first re-encryption under a new key is the moment PEPPA_SECRET changed.
|
||
if (out.reencrypted > 0 || rotatingSecret()) {
|
||
const mark = await getSetting<RotationMark>(db, rotatedKey("PEPPA_SECRET"));
|
||
if (!mark || out.reencrypted > 0) await markSecretRotated(db, "PEPPA_SECRET", by);
|
||
}
|
||
return out;
|
||
}
|
||
|
||
/** A fresh random value for PEPPA_SECRET (48 bytes, base64url). */
|
||
export const newSecretKey = () => randomBytes(48).toString("base64url");
|
||
|
||
/** Revokes every live MCP token of a client for all users (superadmin). */
|
||
export async function revokeClientTokens(db: Db, clientId: string): Promise<number> {
|
||
const rows = await db.update(oauthTokens).set({ revokedAt: new Date() }).where(and(eq(oauthTokens.clientId, clientId), isNull(oauthTokens.revokedAt))).returning({ h: oauthTokens.tokenHash });
|
||
return rows.length;
|
||
}
|
||
|
||
/** Who GITEA_TOKEN is and whether it carries admin rights it should not have. */
|
||
export async function checkGiteaBotToken(env: NodeJS.ProcessEnv = process.env): Promise<{ ok: boolean; login: string | null; admin: boolean; problems: string[] }> {
|
||
const token = env.GITEA_TOKEN;
|
||
if (!token) return { ok: false, login: null, admin: false, problems: [tr("GITEA_TOKEN не задан")] };
|
||
try {
|
||
const me = await new GiteaClient(env.GITEA_URL ?? "https://git.telecom.quest", token).me();
|
||
const problems: string[] = [];
|
||
const bot = env.GITEA_BOT_LOGIN || "peppa-bot";
|
||
if (me.login !== bot) problems.push(tr("токен принадлежит {login}, а не {bot}", { login: me.login, bot }));
|
||
if (me.is_admin) problems.push(tr("{login} — администратор Gitea: снимите админские права, FORGE они не нужны", { login: me.login }));
|
||
return { ok: problems.length === 0, login: me.login, admin: !!me.is_admin, problems };
|
||
} catch (e) {
|
||
return { ok: false, login: null, admin: false, problems: [(e as Error).message] };
|
||
}
|
||
}
|