feat: FIRST_INSTALL_TOKEN to help services like Umbrel secure the first_install endpoint (#3751)

Co-authored-by: dni  <office@dnilabs.com>
This commit is contained in:
Arc
2026-02-25 07:53:59 +01:00
committed by dni ⚡
co-authored by dni ⚡
parent 1d9808b269
commit 40c055e373
10 changed files with 50 additions and 12 deletions
+1
View File
@@ -358,6 +358,7 @@ class UpdateSuperuserPassword(BaseModel):
username: str = Query(default=..., min_length=2, max_length=20)
password: str = Query(default=..., min_length=8, max_length=50)
password_repeat: str = Query(default=..., min_length=8, max_length=50)
first_install_token: str | None = Query(None)
class LoginUsr(BaseModel):
+6
View File
@@ -503,6 +503,12 @@ async def update_ui_customization(
async def first_install(data: UpdateSuperuserPassword) -> JSONResponse:
if not settings.first_install:
raise HTTPException(HTTPStatus.FORBIDDEN, "This is not your first install")
if settings.first_install_token:
if not data.first_install_token:
raise HTTPException(HTTPStatus.UNAUTHORIZED, "Missing first_install_token.")
if settings.first_install_token != data.first_install_token:
raise HTTPException(HTTPStatus.UNAUTHORIZED, "Invalid first_install_token.")
account = await get_account(settings.super_user)
if not account:
raise HTTPException(HTTPStatus.INTERNAL_SERVER_ERROR, "Superuser not found.")