1
0
Fork 0
mirror of synced 2024-06-27 02:31:04 +12:00

hiding stdout and stderr on client execution response

This commit is contained in:
Damodar Lohani 2022-08-14 08:44:17 +00:00
parent f8721329ba
commit 734454ee85

View file

@ -966,6 +966,12 @@ App::post('/v1/functions/:functionId/executions')
->setParam('functionStatus', $execution->getAttribute('status', ''))
->setParam('functionExecutionTime', $execution->getAttribute('time') * 1000); // ms
$roles = Authorization::getRoles();
$isPrivilegedUser = Auth::isPrivilegedUser($roles);
$isAppUser = Auth::isAppUser($roles);
$execution->setAttribute('stdout', ($isPrivilegedUser || $isAppUser) ? $executionResponse['stdout'] : '');
$execution->setAttribute('stderr', ($isPrivilegedUser || $isAppUser) ? $executionResponse['stderr'] : '');
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($execution, Response::MODEL_EXECUTION);
@ -1056,6 +1062,12 @@ App::get('/v1/functions/:functionId/executions/:executionId')
throw new Exception('Execution not found', 404, Exception::EXECUTION_NOT_FOUND);
}
$roles = Authorization::getRoles();
$isPrivilegedUser = Auth::isPrivilegedUser($roles);
$isAppUser = Auth::isAppUser($roles);
$execution->setAttribute('stdout', ($isPrivilegedUser || $isAppUser) ? $execution->getAttribute('stdout') : '');
$execution->setAttribute('stderr', ($isPrivilegedUser || $isAppUser) ? $execution->getAttribute('stderr') : '');
$response->dynamic($execution, Response::MODEL_EXECUTION);
});