diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2015-12-14 13:27:29 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2015-12-14 13:27:29 +0000 |
commit | 3fb89a36cb2c8bead62f4985ebdda1e05f8114df (patch) | |
tree | 844840c13d93f399458986ba88c9d8e983d840d8 /lib/ci/api/helpers.rb | |
parent | 73ba411af9f4552e72230d2b9852399e66a23260 (diff) | |
parent | 6586856a1572535e0b9ca2f9021dfd88a158ffdd (diff) | |
download | gitlab-ce-3fb89a36cb2c8bead62f4985ebdda1e05f8114df.tar.gz |
Merge branch 'ci/persist-registration-token' into 'master'
Persist CI runners registration token
This MR adds feature of persisting CI runners registration token.
User will be able to generate and then reset (if necessary to revoke) this token.
This closes #3703
cc @ayufan
See merge request !2039
Diffstat (limited to 'lib/ci/api/helpers.rb')
-rw-r--r-- | lib/ci/api/helpers.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ci/api/helpers.rb b/lib/ci/api/helpers.rb index 9891b5e38ea..443563c2e4a 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! @@ -18,6 +18,10 @@ module Ci forbidden! unless token && build.valid_token?(token) end + def runner_registration_token_valid? + params[:token] == current_application_settings.ensure_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) |