Remove local admin reset now that AuthGuard owns that recovery flow
Lint / Lint (push) Successful in 42s
Tests / Go backend (push) Successful in 56s
Tests / Dashboard checks (push) Successful in 1m5s
Docker / Docker Build & Push (push) Successful in 4m14s

This project's own "break glass" admin reset never actually touched the
centralized AuthGuard account - it only printed a local one-time code and,
on confirm, wiped this project's local "setup completed" flag so its own
setup screen reappeared, leaving the real AuthGuard account untouched and
orphaned from this project's perspective. AuthGuard now has its own proper
superadmin reset in its web UI, which is where this recovery path belongs
going forward - having every integrated project also show a "Reset admin
account" link that does something different and doesn't actually solve
"I forgot my AuthGuard password" was confusing and redundant.

Removes the backend reset handlers, their routes, the local ResetManager
field/init, any local cleanup method that only existed to serve them, and
the frontend API calls plus the onRequestReset/onConfirmReset wiring that
made the shared AuthPage component's reset link appear.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Gabriel20xxandClaude Sonnet 5 committed 2026-09-02 08:51:22 +02:00
1 parent ec4bdd6ac7
commit 4e39b5ac67
6 files changed
+97 -199

No files matched your search

+1 -68
View File
@@ -210,15 +210,10 @@ type AuthService struct {
db *DB
authGuard *authclient.Client
secureCookie bool
// reset backs CollabTable's own local break-glass recovery flow (see
// handleResetRequest/handleResetConfirm); it is unrelated to AuthGuard,
// which runs its own separate instance of the same ResetManager type for
// its own recovery flow.
reset *sharedauth.ResetManager
}
func newAuthService(authGuard *authclient.Client, db *DB, secureCookie bool) *AuthService {
return &AuthService{db: db, authGuard: authGuard, secureCookie: secureCookie, reset: sharedauth.NewResetManager()}
return &AuthService{db: db, authGuard: authGuard, secureCookie: secureCookie}
}
func normalizeUsername(value string) (string, error) {
@@ -472,68 +467,6 @@ func (a *AuthService) handleStatus(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, a.statusResponse(r.Context(), *profile))
}
// handleResetRequest and handleResetConfirm are CollabTable's own local
// "break glass" account recovery: an operator with shell/log access to this
// container (not to AuthGuard) can recover access to CollabTable's UI
// without knowing the current AuthGuard account's password. This is
// deliberately NOT proxied to AuthGuard's own POST
// /api/password-reset/request|confirm -- a break-glass flow should never
// depend on the very identity service it exists to recover access to, and
// (like GameStream before it) CollabTable's existing frontend only ever
// sends {code}, not a new password, so it was built for a "wipe and redo
// setup" recovery model rather than AuthGuard's "set a specific new
// password" one in any case.
func (a *AuthService) handleResetRequest(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
if _, err := a.reset.Request(); err != nil {
writeJSONError(w, http.StatusInternalServerError, "Unable to create reset code")
return
}
writeJSON(w, http.StatusOK, map[string]bool{"ok": true})
}
// handleResetConfirm validates the one-time code handleResetRequest printed
// to this process's own stdout and, on success, resets the local "setup
// completed" flag so CollabTable's setup screen reappears.
//
// This intentionally does NOT touch the underlying AuthGuard account at all
// (does not delete it, does not change its password): CollabTable's local
// console-access recovery is only ever allowed to affect CollabTable's own
// claim on an identity, never to reach into and mutate the centralized
// identity store other projects may come to share. Concretely, this means
// the account AuthGuard already has is left behind (orphaned, from
// CollabTable's perspective) once this runs; re-running setup with the same
// username/email will hit AuthGuard's own 409 "already in use" and the
// operator will need to either choose a different identity at the setup
// screen or resolve the original account directly against AuthGuard (which
// has its own equivalent break-glass recovery).
func (a *AuthService) handleResetConfirm(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
var request struct {
Code string `json:"code"`
}
if err := decodeJSON(r, &request); err != nil || strings.TrimSpace(request.Code) == "" {
writeJSONError(w, http.StatusBadRequest, "Code required")
return
}
if !a.reset.Confirm(request.Code) {
writeJSONError(w, http.StatusUnauthorized, "Invalid or expired reset code.")
return
}
if err := a.db.ClearSetupClaim(r.Context()); err != nil {
writeJSONError(w, http.StatusInternalServerError, "Reset failed")
return
}
a.clearSessionCookies(w)
writeJSON(w, http.StatusOK, map[string]bool{"ok": true})
}
// handleSetup registers CollabTable's first account against AuthGuard's
// POST /api/register. See the top-of-file doc comment's "Setup flow" section
// for why this needs a small local claim flag instead of a count-based