[Feat] Reuse Isolated User + Default Username#1087
Open
RichardAnderson wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Allows multiple sites on the same server to share an isolated Linux user (and FPM pool) safely. Adds distributed locking around isolated-user mutations, a reserved-username blocklist, an API + UI for picking/creating isolated users on site creation, and refactors PHP-version switching out of the Site model into the action layer.
Changes:
- Concurrency: introduces
Server::isolatedUserLock()and wraps create / delete / PHP-version-switch flows in it; refuses to delete users/pools still used by sibling sites. - Validation/UX: adds
reserved_user_namesconfig (shared with frontend), drops the per-server unique-user constraint, addsGetIsolatedUsersaction +sites.isolated-usersendpoint, and a newIsolatedUserSelectcombobox with auto-suggested usernames. - Idempotency:
create-isolated-user.blade.phpshort-circuits if the user already exists and tightens home-dir permissions.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Feature/SitesTest.php | Adds tests for reuse, isolated-users endpoint, shared-user delete, and PHP version switch behavior. |
| resources/views/ssh/os/create-isolated-user.blade.php | Skips creation if user exists; uses mkdir -p and tighter chmods. |
| resources/js/types/index.d.ts | Exposes reserved_user_names on the shared configs.site type. |
| resources/js/pages/sites/components/isolated-user-select.tsx | New combobox listing existing isolated users with site counts and a "create new" affordance. |
| resources/js/pages/sites/components/create-site.tsx | Wires the new select, suggests usernames using existing+reserved, invalidates query on submit. |
| config/core.php | Adds the reserved_user_names blocklist. |
| app/SiteTypes/AbstractSiteType.php | Locks isolation; skips user/FPM-pool creation when already shared with siblings. |
| app/Models/Site.php | Removes changePHPVersion; adds userSharedWithSiblings/fpmPoolSharedWithSiblings helpers. |
| app/Models/Server.php | Adds isolatedUserLock() cache lock helper. |
| app/Http/Middleware/HandleInertiaRequests.php | Shares reserved usernames with the frontend. |
| app/Http/Controllers/SiteController.php | Adds sites.isolated-users endpoint. |
| app/Actions/SSL/GetMatchingSslCertificates.php | Loosens PHPDoc array shape from non-falsy-string to string. |
| app/Actions/Site/UpdatePHPVersion.php | Centralizes PHP version switching with locking and shared-pool checks. |
| app/Actions/Site/GetIsolatedUsers.php | New action returning isolated users with per-server site counts. |
| app/Actions/Site/DeleteSite.php | Refactored to lock and skip teardown of user/pool still used by siblings. |
| app/Actions/Site/CreateSite.php | Replaces unique-user rule with reserved-name + SSH-user blocklist. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant improvements to the handling of isolated users and PHP version management for sites, focusing on safety, concurrency, and user experience. The main changes include the addition of distributed locking to prevent race conditions when manipulating isolated users, improved validation and error handling, and new endpoints and utilities for managing and suggesting isolated usernames. It also improves the existing reserved user name list to prevent the use of system or privileged accounts as site users, as well as allow isolated users to be shared across sites.
Concurrency and Safety Improvements:
isolatedUserLock) when creating, deleting, or modifying isolated users and their PHP FPM pools to prevent race conditions and ensure that only one operation can proceed per user at a time. This affects site deletion, PHP version updates, and user isolation logic. User-friendly validation errors are now returned if a lock cannot be acquired.Validation and Reserved User Names:
reserved_user_namesconfiguration to block the use of system/service accounts as site users, and updated validation logic to enforce this restriction. The reserved list is now shared with the frontend for consistent validation.API and Utility Additions:
Sitemodel to check if a user or PHP FPM pool is shared with sibling sites, supporting safer resource cleanup.Frontend Enhancements:
Codebase Cleanup:
changePHPVersionmethod from theSitemodel, centralizing PHP version switching logic in the action class for better separation of concerns.These changes collectively enhance the reliability, safety, and usability of isolated user management and PHP version switching in the application.