Compare commits

..
2 Commits
Author SHA1 Message Date
bobbanandClaude Sonnet 5.5 3daec601fd Let a secret be marked as never expiring
The expiry date is now optional: no date means the secret never expires,
gets the status "no expiry" and never raises an alert or reminder. The
Secrets form has a "Never expires" checkbox. Certificates checked against a
host keep their live expiry and can't be set to never expire. Migration
0016 makes secrets.expiry_date nullable.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 01:44:40 +02:00
bobbanandClaude Sonnet 5.5 75f0a3d881 Add an "Open admin" button to the integration pages
Each integration page now has a button next to its title that opens the
product's own admin panel in a new tab, using the address entered on the
integration. Tailscale links to its admin console. Only http(s) addresses
become links.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 01:44:38 +02:00
20 changed files with 2133 additions and 44 deletions

No files matched your search

+1 -1
View File
@@ -361,7 +361,7 @@ tracks *when* something expires; it does not store the secret itself.
| `name` | text NOT NULL | | | `name` | text NOT NULL | |
| `type` | text NOT NULL, default `generic` | `api_token` \| `ssl_certificate` \| `password` \| `generic`. | | `type` | text NOT NULL, default `generic` | `api_token` \| `ssl_certificate` \| `password` \| `generic`. |
| `description`, `notes` | text | | | `description`, `notes` | text | |
| `expiry_date` | text NOT NULL | `YYYY-MM-DD`. For a certificate with a host to check, overwritten from the live certificate. | | `expiry_date` | text | `YYYY-MM-DD`. NULL = never expires (no status, no alert). For a certificate with a host to check, overwritten from the live certificate, and never NULL. |
| `warn_days` | integer NOT NULL, default 30 | How long before expiry to start reminding. | | `warn_days` | integer NOT NULL, default 30 | How long before expiry to start reminding. |
| `check_host`, `check_port` | text / integer | Certificates only: read the expiry from the live certificate at this host:port. | | `check_host`, `check_port` | text / integer | Certificates only: read the expiry from the live certificate at this host:port. |
| `last_checked_at`, `last_check_error` | text | Result of the last live check. | | `last_checked_at`, `last_check_error` | text | Result of the last live check. |
+3 -1
View File
@@ -56,7 +56,9 @@ All modules from the original plan are built:
real TLS connection (daily, and on demand via "Check now"), reads the real TLS connection (daily, and on demand via "Check now"), reads the
certificate's actual expiry, and keeps the date current — so a renewed cert certificate's actual expiry, and keeps the date current — so a renewed cert
is picked up automatically and an unreachable host is flagged instead of is picked up automatically and an unreachable host is flagged instead of
silently going stale silently going stale. A secret that doesn't expire (a break-glass password,
a key with no end date) can be ticked "Never expires": it is listed with the
status "no expiry" and never raises an alert or reminder
- **IP Addresses (IPAM)** — inventory of IPs across vendors/locations, - **IP Addresses (IPAM)** — inventory of IPs across vendors/locations,
with "Sync from Tailscale", "Sync from Proxmox", and "Sync from phpIPAM" with "Sync from Tailscale", "Sync from Proxmox", and "Sync from phpIPAM"
actions to pull in tailnet device IPs, VM/LXC IPs, and phpIPAM's own actions to pull in tailnet device IPs, VM/LXC IPs, and phpIPAM's own
+21
View File
@@ -0,0 +1,21 @@
PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_secrets` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`name` text NOT NULL,
`type` text DEFAULT 'generic' NOT NULL,
`description` text,
`expiry_date` text,
`warn_days` integer DEFAULT 30 NOT NULL,
`notes` text,
`check_host` text,
`check_port` integer,
`last_checked_at` text,
`last_check_error` text,
`created_at` text DEFAULT (current_timestamp) NOT NULL,
`updated_at` text DEFAULT (current_timestamp) NOT NULL
);
--> statement-breakpoint
INSERT INTO `__new_secrets`("id", "name", "type", "description", "expiry_date", "warn_days", "notes", "check_host", "check_port", "last_checked_at", "last_check_error", "created_at", "updated_at") SELECT "id", "name", "type", "description", "expiry_date", "warn_days", "notes", "check_host", "check_port", "last_checked_at", "last_check_error", "created_at", "updated_at" FROM `secrets`;--> statement-breakpoint
DROP TABLE `secrets`;--> statement-breakpoint
ALTER TABLE `__new_secrets` RENAME TO `secrets`;--> statement-breakpoint
PRAGMA foreign_keys=ON;
File diff suppressed because it is too large. Load diff
+7
View File
@@ -113,6 +113,13 @@
"when": 1791407868932, "when": 1791407868932,
"tag": "0015_yellow_scalphunter", "tag": "0015_yellow_scalphunter",
"breakpoints": true "breakpoints": true
},
{
"idx": 16,
"version": "6",
"when": 1791667275424,
"tag": "0016_great_glorian",
"breakpoints": true
} }
] ]
} }
+1 -1
View File
@@ -94,7 +94,7 @@ export const secrets = sqliteTable("secrets", {
name: text("name").notNull(), name: text("name").notNull(),
type: text("type").$type<SecretType>().notNull().default("generic"), type: text("type").$type<SecretType>().notNull().default("generic"),
description: text("description"), description: text("description"),
expiryDate: text("expiry_date").notNull(), // ISO date, e.g. 2026-03-01 expiryDate: text("expiry_date"), // ISO date, e.g. 2026-03-01. NULL = never expires (no status, no reminders).
warnDays: integer("warn_days").notNull().default(30), warnDays: integer("warn_days").notNull().default(30),
notes: text("notes"), notes: text("notes"),
// ssl_certificate secrets only: when set, expiryDate is read from the live certificate on this host:port instead of typed in. // ssl_certificate secrets only: when set, expiryDate is read from the live certificate on this host:port instead of typed in.
+20 -7
View File
@@ -1,5 +1,5 @@
import { Router } from "express"; import { Router } from "express";
import { eq } from "drizzle-orm"; import { eq, sql } from "drizzle-orm";
import { z } from "zod"; import { z } from "zod";
import { db } from "../db/client.js"; import { db } from "../db/client.js";
import { secrets, secretTypes } from "../db/schema.js"; import { secrets, secretTypes } from "../db/schema.js";
@@ -14,7 +14,7 @@ export const secretsRouter = Router();
secretsRouter.use(requireAuth); secretsRouter.use(requireAuth);
secretsRouter.get("/", asyncHandler(async (_req, res) => { secretsRouter.get("/", asyncHandler(async (_req, res) => {
const rows = await db.select().from(secrets).orderBy(secrets.expiryDate); const rows = await db.select().from(secrets).orderBy(sql`${secrets.expiryDate} IS NULL`, secrets.expiryDate);
res.json({ res.json({
secrets: rows.map((s) => ({ ...s, ...computeSecretStatus(s.expiryDate, s.warnDays) })), secrets: rows.map((s) => ({ ...s, ...computeSecretStatus(s.expiryDate, s.warnDays) })),
}); });
@@ -24,8 +24,8 @@ const secretInput = z.object({
name: z.string().min(1).max(200), name: z.string().min(1).max(200),
type: z.enum(secretTypes), type: z.enum(secretTypes),
description: z.string().max(2000).optional(), description: z.string().max(2000).optional(),
// Optional only because a monitored certificate gets its date from the live cert; validated below. // Optional only because a monitored certificate gets its date from the live cert; validated below. null means the secret never expires.
expiryDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Expected YYYY-MM-DD").optional(), expiryDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Expected YYYY-MM-DD").nullable().optional(),
warnDays: z.number().int().min(0).max(3650).default(30), warnDays: z.number().int().min(0).max(3650).default(30),
notes: z.string().max(4000).optional(), notes: z.string().max(4000).optional(),
checkHost: z.string().min(1).max(253).regex(/^[A-Za-z0-9._:-]+$/, "Invalid host").nullable().optional(), checkHost: z.string().min(1).max(253).regex(/^[A-Za-z0-9._:-]+$/, "Invalid host").nullable().optional(),
@@ -43,7 +43,11 @@ secretsRouter.post("/", requireRole("operator"), asyncHandler(async (req, res) =
return res.status(400).json({ error: "invalid_body", message: "Only SSL certificates can be checked against a host." }); return res.status(400).json({ error: "invalid_body", message: "Only SSL certificates can be checked against a host." });
} }
let expiryDate = manualExpiry; if (checkHost && manualExpiry === null) {
return res.status(400).json({ error: "invalid_body", message: "A certificate that is checked against a host has the expiry of the live certificate; it can't be set to never expire." });
}
let expiryDate: string | null | undefined = manualExpiry;
let lastCheckedAt: string | null = null; let lastCheckedAt: string | null = null;
let lastCheckError: string | null = null; let lastCheckError: string | null = null;
if (checkHost) { if (checkHost) {
@@ -60,8 +64,8 @@ secretsRouter.post("/", requireRole("operator"), asyncHandler(async (req, res) =
} }
} }
} }
if (!expiryDate) { if (expiryDate === undefined) {
return res.status(400).json({ error: "invalid_body", message: "An expiry date is required unless a host to check is given." }); return res.status(400).json({ error: "invalid_body", message: "An expiry date is required unless the secret never expires or a host to check is given." });
} }
const [created] = await db const [created] = await db
@@ -101,6 +105,9 @@ secretsRouter.patch("/:id", requireRole("operator"), asyncHandler(async (req, re
// Changing a monitored secret to a non-certificate type quietly ends the monitoring rather than leaving a stale check behind. // Changing a monitored secret to a non-certificate type quietly ends the monitoring rather than leaving a stale check behind.
const nextHost = nextType !== "ssl_certificate" ? null : checkHost !== undefined ? checkHost : existing.checkHost; const nextHost = nextType !== "ssl_certificate" ? null : checkHost !== undefined ? checkHost : existing.checkHost;
const nextPort = checkPort !== undefined ? checkPort : existing.checkPort; const nextPort = checkPort !== undefined ? checkPort : existing.checkPort;
if (nextHost && rest.expiryDate === null) {
return res.status(400).json({ error: "invalid_body", message: "A certificate that is checked against a host has the expiry of the live certificate; it can't be set to never expire." });
}
const now = new Date().toISOString(); const now = new Date().toISOString();
const changes: Partial<typeof secrets.$inferInsert> = { ...rest, updatedAt: now }; const changes: Partial<typeof secrets.$inferInsert> = { ...rest, updatedAt: now };
@@ -117,6 +124,12 @@ secretsRouter.patch("/:id", requireRole("operator"), asyncHandler(async (req, re
} catch (err) { } catch (err) {
// Keep whatever date we already have (a manually supplied one, else the existing one) and record why the check failed. // Keep whatever date we already have (a manually supplied one, else the existing one) and record why the check failed.
changes.lastCheckError = err instanceof Error ? err.message : String(err); changes.lastCheckError = err instanceof Error ? err.message : String(err);
if (!changes.expiryDate && !existing.expiryDate) {
return res.status(400).json({
error: "tls_check_failed",
message: `Couldn't read the certificate from ${nextHost}:${port} (${changes.lastCheckError}), and this secret has no expiry date to fall back on. Fix the host, or enter an expiry date first.`,
});
}
} }
} else { } else {
// Same host as before: the live certificate stays the source of truth, so ignore a hand-typed date. // Same host as before: the live certificate stays the source of truth, so ignore a hand-typed date.
+13 -10
View File
@@ -1,19 +1,22 @@
export type SecretStatus = "ok" | "expiring" | "expired"; export type SecretStatus = "ok" | "expiring" | "expired" | "never";
/** Computes status + days-left for a secret, matching Sloth Manager's original semantics. */ export type SecretStatusResult =
| { status: "ok" | "expiring" | "expired"; daysLeft: number }
| { status: "never"; daysLeft: null };
/** Computes status + days-left for a secret, matching Sloth Manager's original semantics. A secret with no expiry date never expires. */
export function computeSecretStatus( export function computeSecretStatus(
expiryDate: string, expiryDate: string | null,
warnDays: number, warnDays: number,
now: Date = new Date(), now: Date = new Date(),
): { status: SecretStatus; daysLeft: number } { ): SecretStatusResult {
if (!expiryDate) return { status: "never", daysLeft: null };
const expiry = new Date(`${expiryDate}T00:00:00Z`); const expiry = new Date(`${expiryDate}T00:00:00Z`);
const today = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())); const today = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()));
const daysLeft = Math.round((expiry.getTime() - today.getTime()) / (1000 * 60 * 60 * 24)); const daysLeft = Math.round((expiry.getTime() - today.getTime()) / (1000 * 60 * 60 * 24));
let status: SecretStatus; if (daysLeft < 0) return { status: "expired", daysLeft };
if (daysLeft < 0) status = "expired"; if (daysLeft <= warnDays) return { status: "expiring", daysLeft };
else if (daysLeft <= warnDays) status = "expiring"; return { status: "ok", daysLeft };
else status = "ok";
return { status, daysLeft };
} }
+139
View File
@@ -0,0 +1,139 @@
/**
* Secrets that never expire: a secret with no expiry date has no status to warn about, and the API accepts and returns it.
* The routes run for real against a scratch database; only the sign-in is stubbed (every request is an admin).
*
* Run with: npm test --workspace server
*/
import { test, describe, before, after } from "node:test";
import assert from "node:assert/strict";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { AddressInfo } from "node:net";
import type { Server } from "node:http";
const dir = mkdtempSync(join(tmpdir(), "hm-secrets-test-"));
process.env.DATABASE_PATH = join(dir, "test.sqlite");
process.env.SESSION_DIR = join(dir, "sessions");
process.env.CREDENTIALS_ENCRYPTION_KEY = "ab".repeat(32);
const express = (await import("express")).default;
const { db } = await import("../src/db/client.js");
const { users, secrets } = await import("../src/db/schema.js");
const { runMigrations } = await import("../src/db/migrate.js");
const { secretsRouter } = await import("../src/routes/secrets.js");
const { collectAlerts } = await import("../src/services/alerts.js");
const { computeSecretStatus } = await import("../src/services/secretStatus.js");
await runMigrations();
describe("computeSecretStatus", () => {
const now = new Date("2026-10-10T12:00:00Z");
test("a secret without an expiry date never expires", () => {
assert.deepEqual(computeSecretStatus(null, 30, now), { status: "never", daysLeft: null });
});
test("dated secrets keep their ok / expiring / expired meaning", () => {
assert.deepEqual(computeSecretStatus("2026-12-31", 30, now), { status: "ok", daysLeft: 82 });
assert.deepEqual(computeSecretStatus("2026-10-20", 30, now), { status: "expiring", daysLeft: 10 });
assert.deepEqual(computeSecretStatus("2026-10-08", 30, now), { status: "expired", daysLeft: -2 });
});
});
describe("secrets API", () => {
let server: Server;
let base = "";
before(async () => {
await db.insert(users).values({ oidcSub: "tester", name: "Tester", role: "admin" });
const app = express();
app.use(express.json());
app.use((req, _res, next) => {
(req as unknown as { session: unknown }).session = { user: { sub: "tester" } };
next();
});
app.use("/api/secrets", secretsRouter);
server = await new Promise<Server>((resolve) => {
const s = app.listen(0, "127.0.0.1", () => resolve(s));
});
base = `http://127.0.0.1:${(server.address() as AddressInfo).port}/api/secrets`;
});
after(() => {
server.close();
try {
rmSync(dir, { recursive: true, force: true });
} catch {
// Windows keeps the database file locked until the process exits; the folder is in the temp directory anyway.
}
});
async function send(method: string, path: string, body?: unknown) {
const res = await fetch(`${base}${path}`, {
method,
headers: { "content-type": "application/json" },
body: body === undefined ? undefined : JSON.stringify(body),
});
return { status: res.status, body: res.status === 204 ? null : await res.json() };
}
test("a secret can be created without an expiry date and is reported as never expiring", async () => {
const created = await send("POST", "/", { name: "Break-glass admin", type: "password", expiryDate: null });
assert.equal(created.status, 201);
assert.equal(created.body.secret.expiryDate, null);
assert.equal(created.body.secret.status, "never");
assert.equal(created.body.secret.daysLeft, null);
});
test("leaving the date out is still an error — never expiring has to be said explicitly", async () => {
const res = await send("POST", "/", { name: "Forgot the date", type: "generic" });
assert.equal(res.status, 400);
});
test("a dated secret can be switched to never expire and back", async () => {
const created = await send("POST", "/", { name: "API token", type: "api_token", expiryDate: "2030-01-01" });
const id = created.body.secret.id;
assert.equal(created.body.secret.status, "ok");
const never = await send("PATCH", `/${id}`, { expiryDate: null });
assert.equal(never.status, 200);
assert.equal(never.body.secret.expiryDate, null);
assert.equal(never.body.secret.status, "never");
const dated = await send("PATCH", `/${id}`, { expiryDate: "2030-06-01" });
assert.equal(dated.body.secret.expiryDate, "2030-06-01");
assert.equal(dated.body.secret.status, "ok");
});
test("a certificate checked against a host cannot be set to never expire", async () => {
const res = await send("POST", "/", {
name: "Monitored cert",
type: "ssl_certificate",
expiryDate: null,
checkHost: "nas.example.lan",
});
assert.equal(res.status, 400);
});
test("the list puts secrets without a date last, after the dated ones in date order", async () => {
await send("POST", "/", { name: "Soonest", type: "generic", expiryDate: "2026-11-01" });
const list = await send("GET", "/");
const dates = list.body.secrets.map((s: { expiryDate: string | null }) => s.expiryDate);
const firstNever = dates.findIndex((d: string | null) => d === null);
assert.ok(firstNever > 0);
assert.ok(dates.slice(firstNever).every((d: string | null) => d === null), "every undated secret comes after every dated one");
const dated = dates.slice(0, firstNever);
assert.deepEqual(dated, [...dated].sort());
});
test("a secret that never expires raises no alert, an expired one does", async () => {
await db.delete(secrets);
await send("POST", "/", { name: "Never", type: "generic", expiryDate: null });
await send("POST", "/", { name: "Old", type: "generic", expiryDate: "2020-01-01" });
const report = await collectAlerts();
const messages = report.alerts.map((a: { message: string }) => a.message).filter((m: string) => m.startsWith("Secret"));
assert.equal(messages.length, 1);
assert.match(messages[0], /Old/);
});
});
+7 -4
View File
@@ -78,20 +78,22 @@ export interface DiagLogResponse {
} }
export type SecretType = "api_token" | "ssl_certificate" | "password" | "generic"; export type SecretType = "api_token" | "ssl_certificate" | "password" | "generic";
export type SecretStatus = "ok" | "expiring" | "expired"; export type SecretStatus = "ok" | "expiring" | "expired" | "never";
export interface SecretRecord { export interface SecretRecord {
id: number; id: number;
name: string; name: string;
type: SecretType; type: SecretType;
description: string | null; description: string | null;
expiryDate: string; /** null = never expires. */
expiryDate: string | null;
warnDays: number; warnDays: number;
notes: string | null; notes: string | null;
createdAt: string; createdAt: string;
updatedAt: string; updatedAt: string;
status: SecretStatus; status: SecretStatus;
daysLeft: number; /** null when the secret never expires. */
daysLeft: number | null;
/** ssl_certificate only — when set, expiryDate is read from the live certificate here rather than typed in. */ /** ssl_certificate only — when set, expiryDate is read from the live certificate here rather than typed in. */
checkHost: string | null; checkHost: string | null;
checkPort: number | null; checkPort: number | null;
@@ -104,7 +106,8 @@ export interface SecretInput {
type: SecretType; type: SecretType;
description?: string; description?: string;
/** Omitted when a host to check is given — the date then comes from the live certificate. */ /** Omitted when a host to check is given — the date then comes from the live certificate. */
expiryDate?: string; /** null = never expires. */
expiryDate?: string | null;
warnDays: number; warnDays: number;
notes?: string; notes?: string;
checkHost?: string | null; checkHost?: string | null;
@@ -0,0 +1,48 @@
import type { IntegrationSummary } from "../api/client";
/** Only http(s) addresses become links, so a stored value can never turn into a javascript: link. */
function webAddress(value: string | undefined): string | null {
if (!value) return null;
try {
const url = new URL(value);
return url.protocol === "http:" || url.protocol === "https:" ? url.href : null;
} catch {
return null;
}
}
/**
* Page heading for an integration page, with a button that opens the product's own admin panel
* in a new tab. The address is the one entered on the integration (its URL field); `url` overrides
* it for products with no address of their own (Tailscale).
*/
export default function IntegrationPageTitle({
title,
adminName,
integration,
url,
}: {
title: string;
/** Product name for the button when the page title is not it (the Docker page is Dockhand). */
adminName?: string;
integration: IntegrationSummary | null;
url?: string;
}) {
const href = webAddress(url ?? integration?.baseUrl);
return (
<div className="d-flex flex-wrap align-items-center gap-3 mb-3">
<h2 className="page-title mb-0">{title}</h2>
{href && (
<a
className="btn btn-sm btn-outline-secondary"
href={href}
target="_blank"
rel="noopener noreferrer"
title={href}
>
Open {adminName ?? title} admin ↗
</a>
)}
</div>
);
}
+2 -1
View File
@@ -13,6 +13,7 @@ import { usePagination } from "../hooks/usePagination";
import Pagination from "../components/Pagination"; import Pagination from "../components/Pagination";
import { downloadCsv } from "../utils/csv"; import { downloadCsv } from "../utils/csv";
import { confirmDialog } from "../utils/dialogs"; import { confirmDialog } from "../utils/dialogs";
import IntegrationPageTitle from "../components/IntegrationPageTitle";
function updateBadge(c: DockhandContainer) { function updateBadge(c: DockhandContainer) {
if (c.updateAvailable === null) return <span className="text-secondary">—</span>; if (c.updateAvailable === null) return <span className="text-secondary">—</span>;
@@ -140,7 +141,7 @@ export default function Docker({ user }: { user: CurrentUser }) {
return ( return (
<> <>
<h2 className="page-title mb-3">Docker</h2> <IntegrationPageTitle title="Docker" adminName="Dockhand" integration={selected} />
{error && <div className="alert alert-danger">{error}</div>} {error && <div className="alert alert-danger">{error}</div>}
{integrations?.length === 0 ? ( {integrations?.length === 0 ? (
+2 -1
View File
@@ -1,4 +1,5 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import IntegrationPageTitle from "../components/IntegrationPageTitle";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { api, type CurrentUser, type GiteaRepo, type IntegrationSummary } from "../api/client"; import { api, type CurrentUser, type GiteaRepo, type IntegrationSummary } from "../api/client";
import { useSortable } from "../hooks/useSortable"; import { useSortable } from "../hooks/useSortable";
@@ -113,7 +114,7 @@ export default function Gitea({ user }: { user: CurrentUser }) {
return ( return (
<> <>
<h2 className="page-title mb-3">Gitea</h2> <IntegrationPageTitle title="Gitea" integration={selected} />
{error && <div className="alert alert-danger">{error}</div>} {error && <div className="alert alert-danger">{error}</div>}
{integrations?.length === 0 ? ( {integrations?.length === 0 ? (
+2 -1
View File
@@ -11,6 +11,7 @@ import {
import { useSortable } from "../hooks/useSortable"; import { useSortable } from "../hooks/useSortable";
import SortableTh from "../components/SortableTh"; import SortableTh from "../components/SortableTh";
import { downloadCsv } from "../utils/csv"; import { downloadCsv } from "../utils/csv";
import IntegrationPageTitle from "../components/IntegrationPageTitle";
function formatBytes(bytes: number | null): string { function formatBytes(bytes: number | null): string {
if (bytes === null) return "—"; if (bytes === null) return "—";
@@ -126,7 +127,7 @@ export default function PbsBackup({ user: _user }: { user: CurrentUser }) {
return ( return (
<> <>
<h2 className="page-title mb-3">Proxmox Backup Server</h2> <IntegrationPageTitle title="Proxmox Backup Server" integration={selected} />
{error && <div className="alert alert-danger">{error}</div>} {error && <div className="alert alert-danger">{error}</div>}
{integrations?.length === 0 ? ( {integrations?.length === 0 ? (
+2 -1
View File
@@ -16,6 +16,7 @@ import { usePagination } from "../hooks/usePagination";
import Pagination from "../components/Pagination"; import Pagination from "../components/Pagination";
import { downloadCsv } from "../utils/csv"; import { downloadCsv } from "../utils/csv";
import { confirmDialog } from "../utils/dialogs"; import { confirmDialog } from "../utils/dialogs";
import IntegrationPageTitle from "../components/IntegrationPageTitle";
function proxmoxStatusBadge(status: string) { function proxmoxStatusBadge(status: string) {
return status === "running" ? ( return status === "running" ? (
@@ -203,7 +204,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
return ( return (
<> <>
<h2 className="page-title mb-3">Proxmox</h2> <IntegrationPageTitle title="Proxmox" integration={selected} />
{error && <div className="alert alert-danger">{error}</div>} {error && <div className="alert alert-danger">{error}</div>}
{integrations?.length === 0 ? ( {integrations?.length === 0 ? (
+37 -12
View File
@@ -22,6 +22,14 @@ const STATUS_BADGE: Record<SecretStatus, string> = {
ok: "bg-green-lt text-green", ok: "bg-green-lt text-green",
expiring: "bg-yellow-lt text-yellow", expiring: "bg-yellow-lt text-yellow",
expired: "bg-red-lt text-red", expired: "bg-red-lt text-red",
never: "bg-secondary-lt text-secondary",
};
const STATUS_LABEL: Record<SecretStatus, string> = {
ok: "ok",
expiring: "expiring",
expired: "expired",
never: "no expiry",
}; };
const emptyForm: SecretInput = { const emptyForm: SecretInput = {
@@ -45,6 +53,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
const [editingId, setEditingId] = useState<number | null>(null); const [editingId, setEditingId] = useState<number | null>(null);
const [form, setForm] = useState<SecretInput>(emptyForm); const [form, setForm] = useState<SecretInput>(emptyForm);
const [saving, setSaving] = useState(false); const [saving, setSaving] = useState(false);
const [neverExpires, setNeverExpires] = useState(false);
const selection = useSelection<number>(); const selection = useSelection<number>();
const [bulkDeleting, setBulkDeleting] = useState(false); const [bulkDeleting, setBulkDeleting] = useState(false);
const [checkingId, setCheckingId] = useState<number | null>(null); const [checkingId, setCheckingId] = useState<number | null>(null);
@@ -76,11 +85,12 @@ export default function Secrets({ user }: { user: CurrentUser }) {
function startEdit(s: SecretRecord) { function startEdit(s: SecretRecord) {
setEditingId(s.id); setEditingId(s.id);
setNeverExpires(s.expiryDate === null);
setForm({ setForm({
name: s.name, name: s.name,
type: s.type, type: s.type,
description: s.description ?? "", description: s.description ?? "",
expiryDate: s.expiryDate, expiryDate: s.expiryDate ?? "",
warnDays: s.warnDays, warnDays: s.warnDays,
notes: s.notes ?? "", notes: s.notes ?? "",
checkHost: s.checkHost ?? "", checkHost: s.checkHost ?? "",
@@ -90,6 +100,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
function cancelEdit() { function cancelEdit() {
setEditingId(null); setEditingId(null);
setNeverExpires(false);
setForm(emptyForm); setForm(emptyForm);
} }
@@ -102,7 +113,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
const host = form.type === "ssl_certificate" ? (form.checkHost ?? "").trim() : ""; const host = form.type === "ssl_certificate" ? (form.checkHost ?? "").trim() : "";
const payload: SecretInput = { const payload: SecretInput = {
...form, ...form,
expiryDate: host ? undefined : form.expiryDate, expiryDate: host ? undefined : neverExpires ? null : form.expiryDate,
checkHost: host || null, checkHost: host || null,
checkPort: host ? form.checkPort || 443 : null, checkPort: host ? form.checkPort || 443 : null,
}; };
@@ -173,10 +184,10 @@ export default function Secrets({ user }: { user: CurrentUser }) {
s.name, s.name,
TYPE_LABELS[s.type], TYPE_LABELS[s.type],
s.description ?? "", s.description ?? "",
s.expiryDate, s.expiryDate ?? "never expires",
s.warnDays, s.warnDays,
s.status, STATUS_LABEL[s.status],
s.daysLeft, s.daysLeft ?? "",
s.notes ?? "", s.notes ?? "",
s.checkHost ? `${s.checkHost}:${s.checkPort ?? 443}` : "", s.checkHost ? `${s.checkHost}:${s.checkPort ?? 443}` : "",
]), ]),
@@ -225,12 +236,24 @@ export default function Secrets({ user }: { user: CurrentUser }) {
<input <input
type="date" type="date"
className="form-control" className="form-control"
required={!monitoredInForm} required={!monitoredInForm && !neverExpires}
disabled={monitoredInForm} disabled={monitoredInForm || neverExpires}
value={form.expiryDate ?? ""} value={neverExpires ? "" : (form.expiryDate ?? "")}
onChange={(e) => setForm({ ...form, expiryDate: e.target.value })} onChange={(e) => setForm({ ...form, expiryDate: e.target.value })}
/> />
{monitoredInForm && <div className="form-hint">Read from the live certificate.</div>} {monitoredInForm ? (
<div className="form-hint">Read from the live certificate.</div>
) : (
<label className="form-check mt-2 mb-0">
<input
type="checkbox"
className="form-check-input"
checked={neverExpires}
onChange={(e) => setNeverExpires(e.target.checked)}
/>
<span className="form-check-label">Never expires</span>
</label>
)}
</div> </div>
{form.type === "ssl_certificate" && ( {form.type === "ssl_certificate" && (
<> <>
@@ -264,6 +287,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
type="number" type="number"
min={0} min={0}
className="form-control" className="form-control"
disabled={neverExpires && !monitoredInForm}
value={form.warnDays} value={form.warnDays}
onChange={(e) => setForm({ ...form, warnDays: Number(e.target.value) })} onChange={(e) => setForm({ ...form, warnDays: Number(e.target.value) })}
/> />
@@ -319,6 +343,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
<option value="ok">OK</option> <option value="ok">OK</option>
<option value="expiring">Expiring</option> <option value="expiring">Expiring</option>
<option value="expired">Expired</option> <option value="expired">Expired</option>
<option value="never">No expiry</option>
</select> </select>
<button className="btn btn-outline-secondary ms-auto" onClick={exportCsv}> <button className="btn btn-outline-secondary ms-auto" onClick={exportCsv}>
Export CSV Export CSV
@@ -393,7 +418,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
<td>{s.name}</td> <td>{s.name}</td>
<td>{TYPE_LABELS[s.type]}</td> <td>{TYPE_LABELS[s.type]}</td>
<td> <td>
{s.expiryDate} {s.expiryDate ?? <span className="text-secondary">Never</span>}
{s.checkHost && ( {s.checkHost && (
<span <span
className="badge bg-cyan-lt ms-2" className="badge bg-cyan-lt ms-2"
@@ -408,9 +433,9 @@ export default function Secrets({ user }: { user: CurrentUser }) {
</span> </span>
)} )}
</td> </td>
<td>{s.daysLeft < 0 ? `${Math.abs(s.daysLeft)}d ago` : `${s.daysLeft}d`}</td> <td>{s.daysLeft === null ? "—" : s.daysLeft < 0 ? `${Math.abs(s.daysLeft)}d ago` : `${s.daysLeft}d`}</td>
<td> <td>
<span className={`badge ${STATUS_BADGE[s.status]}`}>{s.status}</span> <span className={`badge ${STATUS_BADGE[s.status]}`}>{STATUS_LABEL[s.status]}</span>
</td> </td>
<td className="text-secondary">{s.description ?? "—"}</td> <td className="text-secondary">{s.description ?? "—"}</td>
{canEdit && ( {canEdit && (
+2 -1
View File
@@ -14,6 +14,7 @@ import { usePagination } from "../hooks/usePagination";
import Pagination from "../components/Pagination"; import Pagination from "../components/Pagination";
import { downloadCsv } from "../utils/csv"; import { downloadCsv } from "../utils/csv";
import { confirmDialog } from "../utils/dialogs"; import { confirmDialog } from "../utils/dialogs";
import IntegrationPageTitle from "../components/IntegrationPageTitle";
function semaphoreStatusBadge(template: SemaphoreTemplate) { function semaphoreStatusBadge(template: SemaphoreTemplate) {
const status = template.lastTask?.status; const status = template.lastTask?.status;
@@ -118,7 +119,7 @@ export default function Semaphore({ user }: { user: CurrentUser }) {
return ( return (
<> <>
<h2 className="page-title mb-3">Semaphore</h2> <IntegrationPageTitle title="Semaphore" integration={selected} />
{error && <div className="alert alert-danger">{error}</div>} {error && <div className="alert alert-danger">{error}</div>}
{integrations?.length === 0 ? ( {integrations?.length === 0 ? (
+2 -1
View File
@@ -12,6 +12,7 @@ import {
import { useSortable } from "../hooks/useSortable"; import { useSortable } from "../hooks/useSortable";
import SortableTh from "../components/SortableTh"; import SortableTh from "../components/SortableTh";
import { downloadCsv } from "../utils/csv"; import { downloadCsv } from "../utils/csv";
import IntegrationPageTitle from "../components/IntegrationPageTitle";
function healthBadge(status: string) { function healthBadge(status: string) {
return status === "normal" ? ( return status === "normal" ? (
@@ -133,7 +134,7 @@ export default function Synology({ user: _user }: { user: CurrentUser }) {
return ( return (
<> <>
<h2 className="page-title mb-3">Synology</h2> <IntegrationPageTitle title="Synology" integration={selected} />
{error && <div className="alert alert-danger">{error}</div>} {error && <div className="alert alert-danger">{error}</div>}
{integrations?.length === 0 ? ( {integrations?.length === 0 ? (
+2 -1
View File
@@ -15,6 +15,7 @@ import Pagination from "../components/Pagination";
import { downloadCsv } from "../utils/csv"; import { downloadCsv } from "../utils/csv";
import { useSelection } from "../hooks/useSelection"; import { useSelection } from "../hooks/useSelection";
import { confirmDialog } from "../utils/dialogs"; import { confirmDialog } from "../utils/dialogs";
import IntegrationPageTitle from "../components/IntegrationPageTitle";
const KEY_EXPIRY_WARN_DAYS = 30; const KEY_EXPIRY_WARN_DAYS = 30;
@@ -156,7 +157,7 @@ export default function Tailscale({ user }: { user: CurrentUser }) {
return ( return (
<> <>
<h2 className="page-title mb-3">Tailscale</h2> <IntegrationPageTitle title="Tailscale" url="https://login.tailscale.com/admin/machines" integration={selected} />
{error && <div className="alert alert-danger">{error}</div>} {error && <div className="alert alert-danger">{error}</div>}
{integrations?.length === 0 ? ( {integrations?.length === 0 ? (
+2 -1
View File
@@ -7,6 +7,7 @@ import { usePagination } from "../hooks/usePagination";
import Pagination from "../components/Pagination"; import Pagination from "../components/Pagination";
import { downloadCsv } from "../utils/csv"; import { downloadCsv } from "../utils/csv";
import { readableError } from "../utils/errors"; import { readableError } from "../utils/errors";
import IntegrationPageTitle from "../components/IntegrationPageTitle";
function statusBadge(monitor: UptimeKumaMonitor) { function statusBadge(monitor: UptimeKumaMonitor) {
switch (monitor.status) { switch (monitor.status) {
@@ -97,7 +98,7 @@ export default function UptimeKuma({ user: _user }: { user: CurrentUser }) {
return ( return (
<> <>
<h2 className="page-title mb-3">Uptime Kuma</h2> <IntegrationPageTitle title="Uptime Kuma" integration={selected} />
{error && <div className="alert alert-danger">{error}</div>} {error && <div className="alert alert-danger">{error}</div>}
{integrations?.length === 0 ? ( {integrations?.length === 0 ? (