2016-08-18 12:52:35 -04:00
|
|
|
module Ci
|
|
|
|
class RunnerPolicy < BasePolicy
|
2017-04-06 17:06:42 -04:00
|
|
|
with_options scope: :subject, score: 0
|
|
|
|
condition(:locked, scope: :subject) { @subject.locked? }
|
2016-08-18 12:52:35 -04:00
|
|
|
|
2018-05-10 08:42:55 -04:00
|
|
|
condition(:owned_runner) { @user.ci_owned_runners.exists?(@subject.id) }
|
2016-08-18 12:52:35 -04:00
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
rule { anonymous }.prevent_all
|
2018-05-16 03:56:28 -04:00
|
|
|
|
|
|
|
rule { admin | owned_runner }.policy do
|
|
|
|
enable :assign_runner
|
|
|
|
enable :read_runner
|
|
|
|
enable :update_runner
|
|
|
|
enable :delete_runner
|
|
|
|
end
|
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
rule { ~admin & locked }.prevent :assign_runner
|
2016-08-18 12:52:35 -04:00
|
|
|
end
|
|
|
|
end
|