2.1 KiB
Allow Sign-Up Via Environment Variable
Date: 2026-08-19 Status: Draft
Summary
Replace the current "count of users" check that gates sign-up with a single environment variable. This lets an operator explicitly control whether public sign-up is available, instead of Podstalk inferring it from how many users already exist.
Motivation
Today ServeSignup disables sign-up once a user already exists
(store.UserCount() > 0). That is implicit and easy to get wrong: the
first user must register before anyone can log in, and once that happens
no one can ever register again. Controlling this with an explicit
environment variable is predictable and self-documenting.
Behavior
New environment variable: PODSTALK_ALLOW_SIGNUP.
- Unset or any falsy value (
false,0,no,off): sign-up disabled. - Truthy value (
true,1,yes,on): sign-up enabled.
Default (unset) is disabled.
Changes
main.go
Read PODSTALK_ALLOW_SIGNUP from the environment and resolve it with a
truthy-value parser. Set the resulting boolean on the AuthHandler.
handler/auth.go
- Add an
AllowSignup boolfield toAuthHandler. ServeSignup: redirect to/signinwhen!AllowSignup(replaces theUserCount() > 0check).- Replace the
hasUsers()helper (driven by user count) with a check onAllowSignup, so the Sign In page shows/ hides the "Sign Up" nav link based on whether sign-up is enabled. The sign-in template passesAllowSignupand renders the link with{{if .AllowSignup}}.
Unchanged
store.UserCount() remains in the store package. It is no longer used by
authentication but is left in place as a general utility.
Out of Scope
- No admin/user-management UI to invite specific users.
- No change to the existing
adduserCLI command (operator provisioning still works regardless of the sign-up toggle). - No change to sign-in/sign-out behavior.
Testing
scripts/buildpasses (gofmt, go vet, go build, docker build).- Manual verification is limited by the sandbox; behavior relies on the straightforward boolean branch and the truthy parser.