diff options
author | Grzegorz Bizon <grzegorz.bizon@ntsn.pl> | 2015-12-10 15:50:00 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzegorz.bizon@ntsn.pl> | 2015-12-11 12:39:39 +0300 |
commit | e2e43a114b5af63aad6d9badcb727c8829abb167 (patch) | |
tree | 719e1a14610f8d64cdeb78115fb8a40ce98121a7 /lib | |
parent | 219afbad2adf0c1b7b3d4ccc116f44ba82818cf1 (diff) |
Use new runners registration token to register CI runners
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ci/api/helpers.rb | 6 | ||||
-rw-r--r-- | lib/ci/api/runners.rb | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/ci/api/helpers.rb b/lib/ci/api/helpers.rb index 02502333756..12d7396189d 100644 --- a/lib/ci/api/helpers.rb +++ b/lib/ci/api/helpers.rb @@ -6,7 +6,7 @@ module Ci UPDATE_RUNNER_EVERY = 60 def authenticate_runners! - forbidden! unless params[:token] == GitlabCi::REGISTRATION_TOKEN + forbidden! unless runner_registration_token_valid? end def authenticate_runner! @@ -22,6 +22,10 @@ module Ci forbidden! unless token && build.valid_token?(token) end + def runner_registration_token_valid? + params[:token] == current_application_settings.runners_registration_token + end + def update_runner_last_contact # Use a random threshold to prevent beating DB updates contacted_at_max_age = UPDATE_RUNNER_EVERY + Random.rand(UPDATE_RUNNER_EVERY) diff --git a/lib/ci/api/runners.rb b/lib/ci/api/runners.rb index 1466fe4356e..3edf067f46d 100644 --- a/lib/ci/api/runners.rb +++ b/lib/ci/api/runners.rb @@ -40,7 +40,7 @@ module Ci required_attributes! [:token] runner = - if params[:token] == GitlabCi::REGISTRATION_TOKEN + if runner_registration_token_valid? # Create shared runner. Requires admin access Ci::Runner.create( description: params[:description], |