Add account deletion, data export and a retention sweep - #279
Merged
Conversation
Adds IAccountPurger as the single place that erases everything stored about a user, a self-service DELETE and export endpoint on /api/auth/me, and a daily retention sweep that reuses the same purge code.
…letion # Conflicts: # docs/setup/configuration.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
IAccountPurger, one service that erases everything stored about a user: school users and their grades, absences, agenda entries, semester reports, subject grades, documents and class memberships, plus the account row. The per-user deletions are a single named list of purge steps, so a new user-scoped table is a two-line addition.IDocumentStorage.DeleteAsyncafter the database transaction commits; a missing or unreachable object is logged and counted, never fatal.DeleteBehavior.SetNullon the FK already says.DELETE /api/auth/mepurges the caller's data and then deletes the Keycloak user through the admin REST API using a service-account client (Oidc:AdminClientId/Oidc:AdminClientSecret). Unconfigured, or any failure against Keycloak, logs a warning and leaves local deletion successful.GET /api/auth/me/exportreturns everything stored about the caller asschuly-export.json.LeaveDateis older thanRetention:MonthsAfterLeave(6), and accounts with no authenticated request forRetention:MonthsInactive(12). Both, andRetention:Enabled, are configurable; it reuses the same purge code.ApplicationUser.LastSeenAt, stamped from the JWT validation pipeline at most once an hour, falling back toCreatedAtfor accounts predating the column. The sweep never touches identity-provider users, so a swept account can sign in again and resync.VaultEntryis keyed by plugin namespace and an opaque key, with no user dimension to match on.Closes #274