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>
This commit is contained in:
1 parent
75f0a3d881
commit
3daec601fd
11 files changed
+2069
-36
No files matched your search
+37
-12
@@ -22,6 +22,14 @@ const STATUS_BADGE: Record<SecretStatus, string> = {
|
||||
ok: "bg-green-lt text-green",
|
||||
expiring: "bg-yellow-lt text-yellow",
|
||||
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 = {
|
||||
@@ -45,6 +53,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
const [editingId, setEditingId] = useState<number | null>(null);
|
||||
const [form, setForm] = useState<SecretInput>(emptyForm);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [neverExpires, setNeverExpires] = useState(false);
|
||||
const selection = useSelection<number>();
|
||||
const [bulkDeleting, setBulkDeleting] = useState(false);
|
||||
const [checkingId, setCheckingId] = useState<number | null>(null);
|
||||
@@ -76,11 +85,12 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
|
||||
function startEdit(s: SecretRecord) {
|
||||
setEditingId(s.id);
|
||||
setNeverExpires(s.expiryDate === null);
|
||||
setForm({
|
||||
name: s.name,
|
||||
type: s.type,
|
||||
description: s.description ?? "",
|
||||
expiryDate: s.expiryDate,
|
||||
expiryDate: s.expiryDate ?? "",
|
||||
warnDays: s.warnDays,
|
||||
notes: s.notes ?? "",
|
||||
checkHost: s.checkHost ?? "",
|
||||
@@ -90,6 +100,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
|
||||
function cancelEdit() {
|
||||
setEditingId(null);
|
||||
setNeverExpires(false);
|
||||
setForm(emptyForm);
|
||||
}
|
||||
|
||||
@@ -102,7 +113,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
const host = form.type === "ssl_certificate" ? (form.checkHost ?? "").trim() : "";
|
||||
const payload: SecretInput = {
|
||||
...form,
|
||||
expiryDate: host ? undefined : form.expiryDate,
|
||||
expiryDate: host ? undefined : neverExpires ? null : form.expiryDate,
|
||||
checkHost: host || null,
|
||||
checkPort: host ? form.checkPort || 443 : null,
|
||||
};
|
||||
@@ -173,10 +184,10 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
s.name,
|
||||
TYPE_LABELS[s.type],
|
||||
s.description ?? "",
|
||||
s.expiryDate,
|
||||
s.expiryDate ?? "never expires",
|
||||
s.warnDays,
|
||||
s.status,
|
||||
s.daysLeft,
|
||||
STATUS_LABEL[s.status],
|
||||
s.daysLeft ?? "",
|
||||
s.notes ?? "",
|
||||
s.checkHost ? `${s.checkHost}:${s.checkPort ?? 443}` : "",
|
||||
]),
|
||||
@@ -225,12 +236,24 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
<input
|
||||
type="date"
|
||||
className="form-control"
|
||||
required={!monitoredInForm}
|
||||
disabled={monitoredInForm}
|
||||
value={form.expiryDate ?? ""}
|
||||
required={!monitoredInForm && !neverExpires}
|
||||
disabled={monitoredInForm || neverExpires}
|
||||
value={neverExpires ? "" : (form.expiryDate ?? "")}
|
||||
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>
|
||||
{form.type === "ssl_certificate" && (
|
||||
<>
|
||||
@@ -264,6 +287,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
type="number"
|
||||
min={0}
|
||||
className="form-control"
|
||||
disabled={neverExpires && !monitoredInForm}
|
||||
value={form.warnDays}
|
||||
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="expiring">Expiring</option>
|
||||
<option value="expired">Expired</option>
|
||||
<option value="never">No expiry</option>
|
||||
</select>
|
||||
<button className="btn btn-outline-secondary ms-auto" onClick={exportCsv}>
|
||||
Export CSV
|
||||
@@ -393,7 +418,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
<td>{s.name}</td>
|
||||
<td>{TYPE_LABELS[s.type]}</td>
|
||||
<td>
|
||||
{s.expiryDate}
|
||||
{s.expiryDate ?? <span className="text-secondary">Never</span>}
|
||||
{s.checkHost && (
|
||||
<span
|
||||
className="badge bg-cyan-lt ms-2"
|
||||
@@ -408,9 +433,9 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
</span>
|
||||
)}
|
||||
</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>
|
||||
<span className={`badge ${STATUS_BADGE[s.status]}`}>{s.status}</span>
|
||||
<span className={`badge ${STATUS_BADGE[s.status]}`}>{STATUS_LABEL[s.status]}</span>
|
||||
</td>
|
||||
<td className="text-secondary">{s.description ?? "—"}</td>
|
||||
{canEdit && (
|
||||
|
||||
Reference in new issue
Block a user