Make self-service signup opt-in via SIGNUP_ENABLED

/users/signup answers 403 unless SIGNUP_ENABLED is set. A public
GET /utils/config/ tells the login page, which hides the sign-up link,
and the signup page explains that an administrator creates accounts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013GAeg4Jo6xjZzjwy9QDWMQ
This commit is contained in:
2026-10-06 11:24:27 +02:00
co-authored by Claude Opus 5.5
parent 6e18ab96ce
commit de7ee759f9
12 changed files with 136 additions and 17 deletions
+2
View File
@@ -154,6 +154,8 @@ def register_user(session: SessionDep, user_in: UserRegister) -> Any:
"""
Create new user without the need to be logged in.
"""
if not settings.SIGNUP_ENABLED:
raise HTTPException(status_code=403, detail="Signup is disabled")
user = crud.get_user_by_email(session=session, email=user_in.email)
if user:
raise HTTPException(
+14
View File
@@ -3,9 +3,11 @@ from typing import Any
from fastapi import APIRouter, Depends, Request, Response
from fastapi.concurrency import run_in_threadpool
from pydantic import BaseModel
from pydantic.networks import EmailStr
from fluksio.api.deps import get_current_active_superuser
from fluksio.core.config import settings
from fluksio.flow.state import RedisState
from fluksio.models import Message
from fluksio.utils import generate_test_email, send_email
@@ -31,6 +33,18 @@ def test_email(email_to: EmailStr) -> Message:
return Message(message="Test email sent")
class PublicConfig(BaseModel):
"""What a browser needs to know about this instance before signing in."""
signup_enabled: bool
@router.get("/config/", response_model=PublicConfig)
def read_config() -> Any:
"""The settings the login page reads. Unauthenticated, so nothing secret."""
return PublicConfig(signup_enabled=settings.SIGNUP_ENABLED)
@router.get("/health-check/")
async def health_check() -> bool:
return True