Record sign-ins, new accounts, automatic log trimming and what settings changed
A check of every write path found gaps in what the audit log captured: - Sign-ins and sign-outs are now recorded with the IP they came from (sign-out is recorded first and can't block signing out). - A new account is recorded when it's created on first sign-in, including when the very first user becomes admin - so the log shows who gained access, not only who changed things. - The automatic log purge, which deletes audit entries, now records itself, attributed to "system". recordAudit() takes an optional actor for this. It only records when something was actually deleted. - Settings updates record what changed (before and after) instead of only which sections were touched. The notification channels (Gotify, ntfy, SMTP, webhook) record field names only: they hold credentials, and webhook URLs and public ntfy topics act as secrets, while the audit log is readable by operators and Settings is admin-only. - Integration edits record renames, enabling/disabling, whether credentials were replaced (never the credentials), and which settings fields changed (names only). The Privacy page and README now say sign-ins store an IP in the audit log. Verified through the real routes against a scratch database: user creation, the logout route, the automatic purge, settings and integration edits - including that a secret token and a webhook URL appear nowhere in the stored entries. The sign-in callback itself needs a real identity provider and wasn't run. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
22cfdbede0
commit
88d9c8e097
9 files changed
+129
-12
No files matched your search
@@ -139,10 +139,18 @@ integrationsRouter.patch("/:id", requireRole("admin"), asyncHandler(async (req,
|
||||
let credentialId = existing.credentialId;
|
||||
let configJson = existing.config;
|
||||
let baseUrl = existing.baseUrl;
|
||||
// For the audit entry: what this edit actually changed. Names only for settings (operators can read the audit
|
||||
// log but not an integration's config), and never anything about the credentials beyond "they were replaced".
|
||||
let credentialsReplaced = false;
|
||||
let fieldsChanged: string[] = [];
|
||||
|
||||
if (parsed.data.config) {
|
||||
const loaded = await loadIntegrationConfig(id);
|
||||
const { secretFields, nonSecretFields } = splitIntegrationConfig(existing.type, parsed.data.config);
|
||||
credentialsReplaced = Object.keys(secretFields).length > 0;
|
||||
fieldsChanged = Object.keys(nonSecretFields).filter(
|
||||
(key) => String(loaded?.config[key] ?? "") !== String(nonSecretFields[key] ?? ""),
|
||||
);
|
||||
const mergedNonSecret = { ...(loaded?.config ?? {}), ...nonSecretFields };
|
||||
for (const field of INTEGRATION_FIELDS[existing.type] ?? []) {
|
||||
if (field.secret) delete (mergedNonSecret as Record<string, unknown>)[field.key];
|
||||
@@ -188,7 +196,13 @@ integrationsRouter.patch("/:id", requireRole("admin"), asyncHandler(async (req,
|
||||
action: "update",
|
||||
targetType: "integration",
|
||||
targetId: id,
|
||||
detail: { name: updated.name },
|
||||
detail: {
|
||||
name: updated.name,
|
||||
...(existing.name !== updated.name ? { renamedFrom: existing.name } : {}),
|
||||
...(existing.enabled !== updated.enabled ? { enabled: updated.enabled } : {}),
|
||||
credentialsReplaced,
|
||||
fieldsChanged,
|
||||
},
|
||||
});
|
||||
|
||||
res.json({
|
||||
|
||||
Reference in new issue
Block a user