diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-02-16 01:30:46 +0100 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-02-16 01:30:46 +0100 |
commit | e25f26e5503a5aa07f5cfc436e10b92254185f9a (patch) | |
tree | d0c93d14bba4c8caa86a8c6af57acdab3c2c54a4 /lib/api/helpers/runner.rb | |
parent | 22c983d7a0219e48856800405aec7d9b930fc9a1 (diff) | |
download | gitlab-ce-feature/runners-v4-api.tar.gz |
Rename API::Ci to API::Runnerfeature/runners-v4-api
Diffstat (limited to 'lib/api/helpers/runner.rb')
-rw-r--r-- | lib/api/helpers/runner.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/api/helpers/runner.rb b/lib/api/helpers/runner.rb new file mode 100644 index 00000000000..119ca81b883 --- /dev/null +++ b/lib/api/helpers/runner.rb @@ -0,0 +1,23 @@ +module API + module Helpers + module Runner + def runner_registration_token_valid? + ActiveSupport::SecurityUtils.variable_size_secure_compare(params[:token], + current_application_settings.runners_registration_token) + end + + def get_runner_version_from_params + return unless params['info'].present? + attributes_for_keys(%w(name version revision platform architecture), params['info']) + end + + def authenticate_runner! + forbidden! unless current_runner + end + + def current_runner + @runner ||= ::Ci::Runner.find_by_token(params[:token].to_s) + end + end + end +end |