ENH handle sub-urls

This commit is contained in:
Andrew Paxley 2023-11-03 14:54:31 +13:00
parent 2cb84e90d4
commit b9b891d050
4 changed files with 15 additions and 3 deletions

View File

@ -44,6 +44,11 @@ class DevelopmentAdminConfirmationMiddleware extends PermissionAwareConfirmation
}
$registeredRoutes = DevelopmentAdmin::config()->get('registered_controllers');
while (!isset($registeredRoutes[$action]) && strpos($action, '/') !== false) {
// Check for the parent route if a specific route isn't found
$action = substr($action, 0, strrpos($action, '/'));
}
if (isset($registeredRoutes[$action]['controller'])) {
$initPermissions = Config::forClass($registeredRoutes[$action]['controller'])->get('init_permissions');
foreach ($initPermissions as $permission) {

View File

@ -39,8 +39,7 @@ class URLSpecialsMiddleware extends PermissionAwareConfirmationMiddleware
parent::__construct(
new ConfirmationMiddleware\GetParameter("flush"),
new ConfirmationMiddleware\GetParameter("isDev"),
new ConfirmationMiddleware\GetParameter("isTest"),
new ConfirmationMiddleware\UrlPathStartswith("dev/build")
new ConfirmationMiddleware\GetParameter("isTest")
);
}

View File

@ -23,6 +23,13 @@ class CleanupTestDatabasesTask extends BuildTask
public function run($request)
{
if (!$this->canView()) {
$response = Security::permissionFailure();
if ($response) {
$response->output();
}
die;
}
TempDatabase::create()->deleteAll();
}

View File

@ -10,6 +10,7 @@ use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Environment;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Manifest\ClassLoader;
use SilverStripe\Dev\DevBuildController;
use SilverStripe\Dev\DevelopmentAdmin;
use SilverStripe\ORM\Connect\DatabaseException;
use SilverStripe\ORM\Connect\TableBuilder;
@ -367,7 +368,7 @@ class DatabaseAdmin extends Controller
// We need to ensure that DevelopmentAdminTest can simulate permission failures when running
// "dev/tests" from CLI.
|| (Director::is_cli() && $allowAllCLI)
|| Permission::check(['ADMIN', 'ALL_DEV_ADMIN', 'CAN_DEV_BUILD'])
|| Permission::check(DevBuildController::config()->get('init_permissions'))
);
}