Repository navigation
Harden installer state guards and seal install endpoints once installed - #459
Merged
navneetkumar-pim-webkul merged 7 commits intoJun 4, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the UnoPim installer by sealing /install routes and installer API endpoints after installation completes, using storage/installed as the completion marker and adding defense-in-depth guards inside installer endpoints.
Changes:
- Seal all
/installtraffic oncestorage/installedexists (including XHR/AJAX), removing the previous AJAX bypass surface. - Add a controller-level
abortIfInstalled()guard to state-changing installer endpoints, and ensure the completion marker is written at the end of the UI flow (admin step or demo-data step). - Add/adjust automated coverage (Pest + Playwright) around installer sealing behavior and marker semantics.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
tests/e2e-pw/tests/08-security/installer-takeover.spec.js |
New Playwright e2e assertions that installer endpoints are sealed on installed instances. |
packages/Webkul/Installer/tests/Feature/InstallerSecurityTest.php |
New feature tests covering AJAX-bypass regression, defense-in-depth controller forbids, and marker timing. |
packages/Webkul/Installer/tests/Feature/InstallerMarkInstalledTest.php |
Verifies CLI installer sealing via markInstalled() and idempotent event dispatch. |
packages/Webkul/Installer/tests/Feature/InstallerCsrfRetryTest.php |
Adjusts test harness to simulate “install in progress” by temporarily removing the installed marker. |
packages/Webkul/Installer/tests/Feature/InstallerControllerTest.php |
Adjusts test harness to remove/restore the marker so controller tests don’t get blocked by the new guard. |
packages/Webkul/Installer/src/Resources/views/installer/index.blade.php |
UI now posts seed_sample_data to allow correct “seal after demo-data” behavior. |
packages/Webkul/Installer/src/Http/Middleware/CanInstall.php |
Installer sealing now applies to all /install requests once completed (no AJAX exception). |
packages/Webkul/Installer/src/Http/Controllers/InstallerController.php |
Adds abortIfInstalled(), introduces UI-flow marker writing, removes dd() in favor of reporting + JSON error. |
packages/Webkul/Installer/src/Console/Commands/Installer.php |
Ensures CLI installs always write storage/installed and dispatch unopim.installed exactly once. |
Comments suppressed due to low confidence (1)
packages/Webkul/Installer/src/Http/Controllers/InstallerController.php:280
smtpConfigSetup()duplicates the marker write + event dispatch logic instead of reusingmarkInstalled(). Reusing the helper keeps the sealing behavior consistent (and benefits frommarkInstalled()idempotency).
$this->environmentManager->setEnvConfiguration(request()->input());
$filePath = storage_path('installed');
File::put($filePath, 'Your UnoPim App is Successfully Installed');
Event::dispatch('unopim.installed');
return $filePath;
…eep admin-setup error shape
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
packages/Webkul/Installer/src/Http/Controllers/InstallerController.php:280
smtpConfigSetup()now hasabortIfInstalled(), but it still writesstorage/installedand dispatchesunopim.installeddirectly. That bypasses the newmarkInstalled()idempotency guard and can re-dispatch the event / overwrite the marker contents. Reuse$this->markInstalled()here instead of duplicating the seal logic.
$this->abortIfInstalled();
$this->environmentManager->setEnvConfiguration(request()->input());
$filePath = storage_path('installed');
File::put($filePath, 'Your UnoPim App is Successfully Installed');
Event::dispatch('unopim.installed');
This was referenced Jun 4, 2026
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.
Description
Tightens the installer access controls so the
/installroutes and their API endpoints can no longer be reached once an instance is fully installed.CanInstallmiddleware now seals all/installrequests once installation is complete, based solely on thestorage/installedcompletion marker (instead of the previous request-type-based check).abortIfInstalled()) to every state-changing installer endpoint —env-file-setup,run-migration,run-seeder,admin-config-setup,seed-sample-data,smtp-config-setup— so they refuse to run on a live instance even if the middleware is bypassed.How To Test This?
Automated
./vendor/bin/pest packages/Webkul/Installer/tests/Feature/InstallerSecurityTest.php→ 9 passed./vendor/bin/pest --testsuite="Installer Feature Test"→ 46 passedBASE_URL=http://127.0.0.1:<port> npx playwright test tests/08-security/installer-takeover.spec.js→ 3 passedManual (on an installed instance)
/install/api/admin-config-setupwith headerX-Requested-With: XMLHttpRequestand a JSON admin payload.302redirect to the dashboard (or403) — not200.adminstable is unchanged and no new account was created.storage/installedmarker) still completes normally end-to-end.Documentation
No documentation changes required.
Branch Selection
Pint
./vendor/bin/pint— passed on all changed files.Tailwind Reordering