Repository navigation
Protected superadmin, re-asserted on every deploy - #14
Merged
Merged
Conversation
The platform owner's account must always exist and never be lockable out. - Migration 0004: users.protected, plus triggers that refuse, for every caller, any change that would lock a protected User out: suspend, soft- or hard-delete, clear protected, change email or test_mode, drop its superadmin role, or schedule its erasure. SET LOCAL app.protected_user_maintenance = 'on' lifts it for one transaction, for handing ownership over. Numbered 0004 to ship ahead of 0003_push. - EnsureProtectedSuperadmin: idempotent; creates the account (active, verified, no password) or restores it to active + protected + superadmin. Never touches an existing password. - cmd/migrate runs it after migrations when SUPERADMIN_EMAIL is set, and deploy.yml passes the SUPERADMIN_EMAIL repository variable, so every deploy re-asserts it. - The API returns 409 user_protected instead of a failed write for delete, suspend, status/email PATCH, erasure, and superadmin role removal. - Docs: Users → The protected superadmin, Database Schema → users, NFR → Bootstrapping, README one-time setup step 6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 of 4 tasks
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
The platform owner's account (
SUPERADMIN_EMAIL, set to the owner's address as a repository variable) always exists as an active superadmin and can't be locked out.0004_protected_superadmin.sql:users.protectedplus database triggers refusing suspend, delete, un-protect, email/test-mode change, superadmin-role removal, and erasure for a protected User, from any caller.app.protected_user_maintenance = 'on'lifts it for one transaction (ownership hand-over). Numbered 0004 so it ships ahead of Implement push notifications and the notification inbox #12's0003_push.sql; migrations apply any unrecorded version in order, and the two touch disjoint tables.cmd/migraterunsEnsureProtectedSuperadminwhenSUPERADMIN_EMAILis set;deploy.ymlpasses the variable. Created without a password; never changes an existing one.409 user_protectedfor delete, suspend, status/emailPATCH, erasure, and removingrole_platform_superadmin.Test plan
TestProtectedSuperadmin: idempotent ensure, every API path refused, direct SQL refused, maintenance override, next ensure restoresgo test ./...,gofmt,go vet🤖 Generated with Claude Code