forked from wrenn/wrenn
v0.1.3 (#36)
## What's new Compliance, audit, and account lifecycle improvements — admin actions are now fully auditable, user data is properly anonymized on deletion, and OAuth signup flow gives users control over their profile. ### Audit - Added audit logging for all admin actions (user activate/deactivate, team BYOC toggle, team delete, template delete, build create/cancel) - Added admin audit page with infinite scroll and hierarchical filters - Fixed audit log team assignment — admin/host actions now correctly land under PlatformTeamID - Anonymize audit logs on user hard-delete (actor name, IDs, emails stripped) - Deduplicated audit logger internals (665 → 374 lines, no behavior change) ### Authentication - Separated GitHub OAuth login/signup flows — login no longer auto-creates accounts - Added name confirmation dialog for new GitHub signups ### Account Lifecycle - Email notification sent when account is permanently deleted after grace period - Audit log anonymization tied to user purge (per-user transactional) ### UX - Removed accent gradient bars from admin host dialogs (border + shadow only) - Frontend renders deleted users as styled badge in audit log view ### Others - Version bump - Bug fixes Reviewed-on: wrenn/wrenn#36
This commit is contained in:
@ -14,6 +14,8 @@ import (
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
|
||||
"git.omukk.dev/wrenn/wrenn/internal/api"
|
||||
"git.omukk.dev/wrenn/wrenn/internal/email"
|
||||
"git.omukk.dev/wrenn/wrenn/pkg/audit"
|
||||
@ -22,6 +24,7 @@ import (
|
||||
"git.omukk.dev/wrenn/wrenn/pkg/channels"
|
||||
"git.omukk.dev/wrenn/wrenn/pkg/config"
|
||||
"git.omukk.dev/wrenn/wrenn/pkg/db"
|
||||
"git.omukk.dev/wrenn/wrenn/pkg/id"
|
||||
"git.omukk.dev/wrenn/wrenn/pkg/lifecycle"
|
||||
"git.omukk.dev/wrenn/wrenn/pkg/logging"
|
||||
"git.omukk.dev/wrenn/wrenn/pkg/scheduler"
|
||||
@ -185,10 +188,12 @@ func Run(opts ...Option) {
|
||||
channelDispatcher.Start(ctx)
|
||||
|
||||
// Start host monitor (passive + active reconciliation every 30s).
|
||||
monitor := api.NewHostMonitor(queries, hostPool, al, 30*time.Second)
|
||||
monitor := api.NewHostMonitor(queries, hostPool, al, 15*time.Second)
|
||||
monitor.Start(ctx)
|
||||
|
||||
// Hard-delete accounts that have been soft-deleted for more than 15 days (runs every 24h).
|
||||
// Audit logs referencing deleted users are anonymized before the user row is removed.
|
||||
// A notification email is sent to the user before their data is permanently removed.
|
||||
go func() {
|
||||
ticker := time.NewTicker(24 * time.Hour)
|
||||
defer ticker.Stop()
|
||||
@ -197,10 +202,34 @@ func Run(opts ...Option) {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
if err := queries.HardDeleteExpiredUsers(ctx); err != nil {
|
||||
slog.Error("account cleanup: failed to hard-delete expired users", "error", err)
|
||||
} else {
|
||||
slog.Info("account cleanup: hard-deleted expired users")
|
||||
expired, err := queries.ListExpiredSoftDeletedUsers(ctx)
|
||||
if err != nil {
|
||||
slog.Error("account cleanup: failed to list expired users", "error", err)
|
||||
continue
|
||||
}
|
||||
var deleted int
|
||||
for _, row := range expired {
|
||||
prefixedID := id.FormatUserID(row.ID)
|
||||
if err := queries.AnonymizeAuditLogsByUserID(ctx, pgtype.Text{String: prefixedID, Valid: true}); err != nil {
|
||||
slog.Error("account cleanup: failed to anonymize audit logs, skipping delete", "user_id", prefixedID, "error", err)
|
||||
continue
|
||||
}
|
||||
if err := queries.HardDeleteUser(ctx, row.ID); err != nil {
|
||||
slog.Error("account cleanup: failed to hard-delete user", "user_id", prefixedID, "error", err)
|
||||
continue
|
||||
}
|
||||
if err := mailer.Send(ctx, row.Email, "Your Wrenn account has been deleted", email.EmailData{
|
||||
Message: "Your Wrenn account and all associated data have been permanently deleted. " +
|
||||
"This action was taken automatically because your account was scheduled for deletion more than 15 days ago.\n\n" +
|
||||
"If you believe this was done in error, please contact support.",
|
||||
Closing: "Thank you for using Wrenn.",
|
||||
}); err != nil {
|
||||
slog.Warn("account cleanup: failed to send deletion notification", "email", row.Email, "error", err)
|
||||
}
|
||||
deleted++
|
||||
}
|
||||
if len(expired) > 0 {
|
||||
slog.Info("account cleanup: processed expired users", "total", len(expired), "deleted", deleted)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user