diff options
Diffstat (limited to 'lib/api/helpers/runner.rb')
-rw-r--r-- | lib/api/helpers/runner.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/api/helpers/runner.rb b/lib/api/helpers/runner.rb index fa8b9ad79bd..1f1253c8542 100644 --- a/lib/api/helpers/runner.rb +++ b/lib/api/helpers/runner.rb @@ -45,7 +45,7 @@ module API end def authenticate_job! - job = Ci::Build.find_by_id(params[:id]) + job = current_job validate_job!(job) do forbidden! unless job_token_valid?(job) @@ -54,6 +54,10 @@ module API job end + def current_job + @current_job ||= Ci::Build.find_by_id(params[:id]) + end + def job_token_valid?(job) token = (params[JOB_TOKEN_PARAM] || env[JOB_TOKEN_HEADER]).to_s token && job.valid_token?(token) |