feat: add ALLOW_SIGNUP + ALLOWED_EMAIL_* for self-hosted instances#1098
feat: add ALLOW_SIGNUP + ALLOWED_EMAIL_* for self-hosted instances#1098azaanaliraza wants to merge 5 commits intomultica-ai:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
There was a problem hiding this comment.
Pull request overview
Adds self-hosting controls to disable or restrict new user signups by configuration, enforcing restrictions in the auth flow and adjusting landing-page copy accordingly.
Changes:
- Added server-side gating in
findOrCreateUserusingALLOW_SIGNUP,ALLOWED_EMAIL_DOMAINS, andALLOWED_EMAILS, returning 403 for prohibited registrations. - Updated landing-page English copy to reflect “Login” instead of “Sign up” when signups are disabled.
- Documented new environment variables in
.env.example.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
server/internal/handler/auth.go |
Enforces signup restrictions during user creation and maps prohibited signups to HTTP 403. |
apps/web/features/landing/i18n/en.ts |
Adjusts English landing copy based on a public env flag. |
.env.example |
Documents new self-hosting environment variables for signup control. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks for working on this — overall this looks like a useful addition for self-hosted setups. A few things stood out to me, though I may be reading parts of this wrong:
Small implementation note: Happy to be wrong on any of the above — just wanted to flag them in case they’re helpful. |
5f440ed to
97cb796
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes multica-ai#930 - Added environment variables to control signups - Updated frontend to hide signup text when disabled - Added backend check to block new user creation via magic link - Updated .env.example
3d04a84 to
b049a3b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // New user creation path. Check if signups are allowed. | ||
| if err := h.checkSignupAllowed(email); err != nil { | ||
| return db.User{}, err | ||
| } |
There was a problem hiding this comment.
Signup gating (ALLOW_SIGNUP / ALLOWED_EMAIL_DOMAINS / ALLOWED_EMAILS) is new behavior but there are no handler tests asserting the expected 403 outcomes or the “existing users can still log in” path. Add tests covering: (1) ALLOW_SIGNUP=false blocks new user registration, (2) allowlist mismatch blocks new user registration, and (3) an existing user can still authenticate when signups are disabled.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Thanks for the detailed review! @sarices Regarding tests: Happy to add them in a follow-up PR if you can point me to similar existing auth tests or give some guidance on the testing pattern used in this codebase. I've addressed the other points:
Let me know if you'd like me to proceed with adding basic tests now. |
What does this PR do?
Closes #930
Adds self-hosting friendly controls to disable or restrict new user signups on private/internal deployments.
Currently, anyone can create an account via the magic-link flow on self-hosted instances. This change gives administrators proper control:
ALLOW_SIGNUP=false→ completely disables new registrationsALLOWED_EMAIL_DOMAINS=company.com,example.org→ restrict to specific domainsALLOWED_EMAILS=...→ allow only exact email addressesWhy this approach?
Related Issue
Closes #930
Type of Change
Changes Made
ALLOW_SIGNUP,ALLOWED_EMAIL_DOMAINS, andALLOWED_EMAILSto.env.exampleapps/web/features/landing/i18n/en.ts) to conditionally hide signup textHow to Test
ALLOW_SIGNUP=true→ normal signup via magic link should workALLOW_SIGNUP=false→ "Sign up" text should be hidden and new registrations should return 403 ForbiddenALLOWED_EMAIL_DOMAINSandALLOWED_EMAILS(if implemented)make check-worktree→ all tests should passChecklist
make check-worktreelocally and tests pass.env.exampleAI Disclosure
AI tool used: Grok (xAI)
Approach: Used Grok to understand the magic-link flow, locate relevant files, and generate the backend check + frontend conditional. Manually verified and applied the changes in the worktree.
Screenshots (optional)