feat(api): GDPR data export as JSON and PDF and account and organization deletion

Users export everything stored about them, organization admins their
organization's configuration, incidents, audit log and daily statistics;
secrets are never included. Users delete their account after confirming
with their password (or email for SSO-only accounts); organizations they
alone belong to go with it, shared ones they own must be handed over
first. Audit entries elsewhere stay as "deleted user". Owners delete
their organization after typing its slug, including check results and
aggregates. Exports and deletions are logged.

Sessions pointing at a deleted organization no longer fail the console.

Closes #66

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 10:10:15 +01:00
1 parent f892f7c03a
commit b58c6d5909
17 files changed
+1821 -47

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
package web
import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
templ exportLinks(base string) {
<p class="mb-6 flex gap-3 text-sm">
<a href={ templ.SafeURL(base + "?format=json") } class="border border-ink px-3 py-1.5 hover:bg-ink hover:text-paper" download>{ i18n.T(ctx, "export.download_json") }</a>
<a href={ templ.SafeURL(base + "?format=pdf") } class="border border-ink px-3 py-1.5 hover:bg-ink hover:text-paper" download>{ i18n.T(ctx, "export.download_pdf") }</a>
</p>
}
// confirmFields asks for the password, or the email address for accounts
// signing in through SSO only.
templ confirmFields(me Me) {
if me.HasPassword {
@field(i18n.T(ctx, "gdpr.password"), "password", "password", "current-password", true)
} else {
@field(i18n.T(ctx, "gdpr.type_email"), "confirm", "email", "off", true)
}
}
templ accountDataSection(me Me) {
<section class="mt-12 max-w-xl">
@sectionHeading("gdpr.account_data")
<p class="mb-4 text-sm text-muted">{ i18n.T(ctx, "gdpr.account_export_intro") }</p>
@exportLinks("/api/v1/me/export")
<h3 class="mb-2 mt-8 text-sm font-medium text-down">{ i18n.T(ctx, "gdpr.delete_account") }</h3>
<p class="mb-4 text-sm text-muted">{ i18n.T(ctx, "gdpr.delete_account_intro") }</p>
<form data-api="/me/delete" data-next="/login" data-confirm={ i18n.T(ctx, "gdpr.delete_account_confirm") }>
@formError()
@confirmFields(me)
<button type="submit" class="mt-2 w-full border border-down px-3 py-2 text-sm font-medium text-down hover:bg-down hover:text-paper disabled:opacity-50">{ i18n.T(ctx, "gdpr.delete_account") }</button>
</form>
</section>
}
templ orgDataSection(me Me) {
<section class="mt-12 max-w-xl">
@sectionHeading("gdpr.org_data")
<p class="mb-4 text-sm text-muted">{ i18n.T(ctx, "gdpr.org_export_intro") }</p>
@exportLinks("/api/v1/org/export")
if me.IsOwner {
<h3 class="mb-2 mt-8 text-sm font-medium text-down">{ i18n.T(ctx, "gdpr.delete_org") }</h3>
<p class="mb-4 text-sm text-muted">{ i18n.T(ctx, "gdpr.delete_org_intro") }</p>
<form data-api="/org/delete" data-next="/" data-confirm={ i18n.T(ctx, "gdpr.delete_org_confirm") }>
@formError()
@field(i18n.T(ctx, "gdpr.type_slug", "Slug", me.ActiveSlug), "slug", "text", "off", true)
@confirmFields(me)
<button type="submit" class="mt-2 w-full border border-down px-3 py-2 text-sm font-medium text-down hover:bg-down hover:text-paper disabled:opacity-50">{ i18n.T(ctx, "gdpr.delete_org") }</button>
</form>
}
</section>
}