Skip to content

Security: lock /setup after owner account is created#86

Open
vdaluz wants to merge 1 commit intosam1am:mainfrom
vdaluz:fix/lock-setup-endpoint
Open

Security: lock /setup after owner account is created#86
vdaluz wants to merge 1 commit intosam1am:mainfrom
vdaluz:fix/lock-setup-endpoint

Conversation

@vdaluz
Copy link
Copy Markdown

@vdaluz vdaluz commented Apr 16, 2026

Problem

/setup and /auth/setup are accessible to anyone at any time, even after the owner account already exists. The route handler does guard against duplicate account creation, but the endpoint itself remains open indefinitely.

Fix

Moves the guard to the middleware layer so both endpoints return a redirect to /login as soon as a user account exists. This is more robust than relying solely on the route handler — it protects against future changes and makes the intent explicit at the routing level.

The check uses the existing user_exists() helper that is already imported in the middleware.

/setup and /auth/setup are currently accessible even after the owner
account exists. Any visitor can hit /setup at any time, which is
surprising and potentially confusing (though account creation itself is
already guarded in the route handler).

Moving the guard to the middleware layer makes the protection consistent
and ensures it applies regardless of how the route handler evolves.
After the first account is created, both endpoints redirect to /login.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant