Every state-changing API route is mapped to an action; a test fails for unmapped routes. Successful changes are recorded with actor, API token, target, IP, user agent and request ID; failed sign-ins too. Names are taken from the response, never secrets. Organizations read their log with audit.read under Settings, users their account activity on the security page, admins the platform log. Entries expire after UPTIME_RETENTION_AUDIT. Closes #65 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
49 lines
1.4 KiB
Templ
49 lines
1.4 KiB
Templ
package web
|
|
|
|
import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
|
|
|
// AuditEntry is one row of an audit log.
|
|
type AuditEntry struct {
|
|
Time string
|
|
Actor string
|
|
Action string
|
|
Target string
|
|
IP string
|
|
RequestID string
|
|
Failed bool
|
|
}
|
|
|
|
templ AuditPage(p Page, me Me, titleID, introID string, entries []AuditEntry, next string) {
|
|
@consoleShell(p, me) {
|
|
@settingsHeading(titleID, introID)
|
|
@auditList(entries)
|
|
if next != "" {
|
|
<a href={ templ.SafeURL(next) } class="mt-4 inline-block text-sm underline underline-offset-2">{ i18n.T(ctx, "audit.older") }</a>
|
|
}
|
|
}
|
|
}
|
|
|
|
templ auditList(entries []AuditEntry) {
|
|
if len(entries) == 0 {
|
|
<p class="text-sm text-muted">{ i18n.T(ctx, "audit.empty") }</p>
|
|
} else {
|
|
<ul class="divide-y divide-rule border-y border-rule text-sm">
|
|
for _, e := range entries {
|
|
<li class="grid gap-x-4 gap-y-0.5 py-2 sm:grid-cols-[10rem_1fr_auto]">
|
|
<span class="font-mono text-xs text-muted">{ e.Time }</span>
|
|
<span>
|
|
<span class={ templ.KV("text-down", e.Failed) }>{ e.Action }</span>
|
|
if e.Target != "" {
|
|
<span class="text-muted">{ " · " + e.Target }</span>
|
|
}
|
|
if e.Actor != "" {
|
|
<span class="block text-xs text-muted">{ e.Actor }</span>
|
|
}
|
|
</span>
|
|
<span class="font-mono text-xs text-muted" title={ e.RequestID }>{ e.IP }</span>
|
|
</li>
|
|
}
|
|
</ul>
|
|
}
|
|
}
|