Commit b5c39e79 authored by Carla Goncalves Ourofino's avatar Carla Goncalves Ourofino
Browse files

Troca lugar de transferência do token para evitar que ele seja persistido em arquivo.

parent 80f6aa60
......@@ -34,3 +34,4 @@ path)
......@@ -21,16 +21,17 @@ end
-- Execute a new command.
-- @param job The job object: is a writable table for driver data.
-- @param cmd_string The command string
-- @param user_token A string with a token to be exported as an envvar.
-- @return True if succeded or nil and an error message
function posix.execute_command(self, job, cmd_string)
function posix.execute_command(self, job, cmd_string, user_token)
self.active_commands = self.active_commands + 1
local job_cmd = cmd_string
-- Export the user token as an environment variable to the command string
if job.parameters.csbase_command_user_token then
job_cmd = "CSBASE_USER_TOKEN="..job.parameters.csbase_command_user_token.." "..job_cmd
if user_token then
job_cmd = "CSBASE_USER_TOKEN="..user_token.." "..job_cmd
for _, sandbox_path in ipairs(job.sandboxes) do
......@@ -220,11 +220,17 @@ function, logger, client, driver)
if sga_name ~= config.sga_name then
return fail_sga_name(sga_name)
-- FIXME Should we get the token from the request header? We could not get header info from API RestServer.
local user_token_key = "csbase_command_user_token"
local user_token = job_request.parameters[user_token_key]
job_request.parameters[user_token_key] = nil
self.logger:info("Received job: "..job_request.cmd_string.." "..job_request.cmd_id.." "..dkjson.encode(job_request.parameters))
local job = self.joblist:new_job(job_request.cmd_id, job_request.cmd_string, job_request.parameters)
local pok, ok, err = pcall(self.driver.execute_command, self.driver, job, job_request.cmd_string)
local pok, ok, err = pcall(self.driver.execute_command, self.driver, job, job_request.cmd_string, user_token)
self.joblist:accept_job(job, pok and ok)
if not pok then
fail(ok, 500)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment