diff --git a/services/nginx/app/routes/moduleSelfServeRoute.php b/services/nginx/app/routes/moduleSelfServeRoute.php index 164cc683..ce0f4451 100644 --- a/services/nginx/app/routes/moduleSelfServeRoute.php +++ b/services/nginx/app/routes/moduleSelfServeRoute.php @@ -67,6 +67,18 @@ class moduleSelfServeRoute if ($command === null) { $response->error("Invalid command: " . $commandParam); } + // Require permissions for specific commands + switch ($command) { + case \modules\selfserve\helpers\selfserve_lane_command::START: + self::requirePermission('modules_selfserve_lane_command_execute_start'); + break; + case \modules\selfserve\helpers\selfserve_lane_command::STOP: + self::requirePermission('modules_selfserve_lane_command_execute_stop'); + break; + case \modules\selfserve\helpers\selfserve_lane_command::RESET: + self::requirePermission('modules_selfserve_lane_command_execute_reset'); + break; + } // Execute the command try { $args = new \modules\selfserve\classes\selfserve_lane_command_arguments(); @@ -87,7 +99,10 @@ class moduleSelfServeRoute } }, [ - 'modules_selfserve_lane_command_execute' => 'Execute self-serve lane command', + 'modules_selfserve_lane_command_execute' => 'Execute self-serve lane command. This is required together with specific command permissions below.', + 'modules_selfserve_lane_command_execute_start' => 'Execute self-serve lane START command', + 'modules_selfserve_lane_command_execute_stop' => 'Execute self-serve lane STOP command', + 'modules_selfserve_lane_command_execute_reset' => 'Execute self-serve lane RESET command', ] ); } diff --git a/services/nginx/app/tests/HTTP/self-serve.http b/services/nginx/app/tests/HTTP/self-serve.http index c62523c1..5b99cbdf 100644 --- a/services/nginx/app/tests/HTTP/self-serve.http +++ b/services/nginx/app/tests/HTTP/self-serve.http @@ -1,5 +1,5 @@ ### POST /modules/self-serve/lane/command START -@lane_id = 3 +@lane_id = 1 POST {{api_url}}/modules/self-serve/lane/command Accept: application/json Content-Type: application/json @@ -16,6 +16,7 @@ Content-Type: application/json POST {{api_url}}/modules/self-serve/lane/command Accept: application/json Content-Type: application/json +Authorization: Bearer {{auth_token_superuser}} { "command": "STOP", @@ -26,6 +27,7 @@ Content-Type: application/json POST {{api_url}}/modules/self-serve/lane/command Accept: application/json Content-Type: application/json +Authorization: Bearer {{auth_token_superuser}} { "command": "RESET",