Skip to content

FOUR-14018: Unauthorized Users Can View Screens, Data Connectors, and Decision Tables #6185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions ProcessMaker/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,11 @@ private function checkAllowedEndpoints(array $projectIds, string $currentPath):
{
$allowedEndpoints = [
'api',
'script/',
'designer/screens',
'processes/',
'designer/decision-tables',
'designer/data-sources',
];

$dataSourceClass = 'ProcessMaker\Packages\Connectors\DataSources\Models\DataSource';
$decisionTableClass = 'ProcessMaker\Package\PackageDecisionEngine\Models\DecisionTable';

// Get the assets associated with the user's projects
$projectAssets = DB::table('project_assets')
->select('asset_id', 'asset_type')
Expand All @@ -156,10 +154,20 @@ private function checkAllowedEndpoints(array $projectIds, string $currentPath):

// Check asset types and push to $allowedEndpoints
if ($assetType === Process::class) {
$allowedEndpoints[] = 'modeler/' . $assetId;
$allowedEndpoints[] = "modeler/{$assetId}";
} elseif ($assetType === Screen::class) {
$allowedEndpoints[] = 'designer/screen-builder/' . $assetId . '/edit';
$allowedEndpoints[] = "designer/screen-builder/{$assetId}/edit";
$allowedEndpoints[] = "designer/screens/{$assetId}/edit";
} elseif ($assetType === Script::class) {
$allowedEndpoints[] = "designer/scripts/{$assetId}/builder";
$allowedEndpoints[] = "designer/scripts/{$assetId}/edit";
}

if (class_exists($dataSourceClass) && $assetType === $dataSourceClass) {
$allowedEndpoints[] = "designer/data-sources/{$assetId}/edit";
}
if (class_exists($decisionTableClass) && $assetType === $decisionTableClass) {
$allowedEndpoints[] = "decision-tables/table-builder/{$assetId}/edit";
$allowedEndpoints[] = 'designer/scripts/' . $assetId . '/builder';
$allowedEndpoints[] = 'designer/scripts/' . $assetId . '/edit';
$allowedEndpoints[] = 'designer/scripts/preview';
Expand Down