diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-02-28 15:29:52 +0300 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-03-02 19:45:46 +0300 |
commit | 7e46db0f5a5b6aa84ac653fa4826b70bf50d6909 (patch) | |
tree | 6aadb1adf61243d17c35fc954d4ac62206efe2ca /lib/api/helpers/runner.rb | |
parent | d5f7e5421157dbd1be134247dfec318c0db546a8 (diff) |
Add job patch trace API
Diffstat (limited to 'lib/api/helpers/runner.rb')
-rw-r--r-- | lib/api/helpers/runner.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/api/helpers/runner.rb b/lib/api/helpers/runner.rb index 15eb6b932ed..e71895c091e 100644 --- a/lib/api/helpers/runner.rb +++ b/lib/api/helpers/runner.rb @@ -1,6 +1,8 @@ module API module Helpers module Runner + JOB_TOKEN_HEADER = 'HTTP_JOB_TOKEN' + JOB_TOKEN_PARAM = :token UPDATE_RUNNER_EVERY = 10 * 60 def runner_registration_token_valid? @@ -55,6 +57,17 @@ module API forbidden!('Project has been deleted!') unless job.project forbidden!('Job has been erased!') if job.erased? end + + def authenticate_job!(job) + validate_job!(job) do + forbidden! unless job_token_valid?(job) + end + end + + def job_token_valid?(job) + token = (params[JOB_TOKEN_PARAM] || env[JOB_TOKEN_HEADER]).to_s + token && job.valid_token?(token) + end end end end |