Skip to content

Add ONBOARD_ALLOW_REGISTRATION to close self-service sign-up on self-hosted installs - #321

Open
shivanathd wants to merge 1 commit into
fleetbase:mainfrom
shivanathd:mindcat/onboard-allow-registration
Open

shivanathd wants to merge 1 commit into
fleetbase:mainfrom
shivanathd:mindcat/onboard-allow-registration

Conversation

@shivanathd

Copy link
Copy Markdown
Contributor

POST /int/v1/onboard/create-account (OnboardController@createAccount) creates a new organization and administrator on every call. GET /int/v1/onboard/should-onboard only decides whether the console shows the setup wizard. So on a self-hosted install, anyone who can reach the API can create their own organization at any time. There is currently no setting to make an install invite-only.

v0.7.73 added OAUTH_ALLOW_REGISTRATION for sign-ups that start from an OAuth provider. This PR adds the matching switch for the regular onboarding endpoint.

Change

  • config/fleetbase.php: onboard.allow_registration, read from ONBOARD_ALLOW_REGISTRATION, default true. Nothing changes unless an operator sets it, so Cloud behaves as today.
  • OnboardController::createAccount: when the flag is false and an organization already exists, return 403 with code: registration_disabled before anything is created. This is the same message and code OAuthController::registrationOutcome() uses. The very first organization can still be created, so a fresh install can still be set up.

OAuth sign-ups also finish through createAccount, so with the flag off they are refused too. That seemed the expected meaning of "sign-up closed". Inviting users into an existing organization doesn't use this endpoint and is unaffected.

Operators who also gate the route at a reverse proxy should match both /int/v1/onboard/create-account and /int/v1/onboard/create-account/ (trailing slash). Otherwise the gate can be bypassed. The flag in this PR doesn't depend on that.

Tests

OnboardControllerTest has two new cases:

  • With the flag off and an organization present, createAccount returns 403 / registration_disabled and creates no user or company.
  • With the flag off on an empty install, the first account is still created as admin.

The shared test config sets the flag to true so the setting can't leak between tests.

I ran tests/Unit/Http/OnboardControllerTest.php on PHP 8.2: 20/20 pass. The refusal case fails on main, as expected. php-cs-fixer --dry-run is clean on the changed files.

This PR was prepared with an AI coding tool (Claude Code) and reviewed by Shiv. Found by Mindcat (mindcat.ai).


Generated by Claude Code

…ign-up

POST /int/v1/onboard/create-account creates a new organization on every
call. should-onboard only hides the console's setup wizard, so a
self-hosted install stays open to sign-ups from anyone who can reach it.

Add fleetbase.onboard.allow_registration (ONBOARD_ALLOW_REGISTRATION,
default true so nothing changes unless an operator opts in). When it is
false and an organization already exists, createAccount answers 403 with
code registration_disabled, the same shape OAuth uses for
OAUTH_ALLOW_REGISTRATION. The first organization can still be created.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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