2020-03-12 08:09:17 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AuthorizedKeysWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
2020-03-23 14:09:25 -04:00
|
|
|
PERMITTED_ACTIONS = %w[add_key remove_key].freeze
|
2020-03-12 08:09:17 -04:00
|
|
|
|
|
|
|
feature_category :source_code_management
|
|
|
|
urgency :high
|
|
|
|
weight 2
|
|
|
|
idempotent!
|
|
|
|
|
|
|
|
def perform(action, *args)
|
|
|
|
return unless Gitlab::CurrentSettings.authorized_keys_enabled?
|
|
|
|
|
2020-03-23 14:09:25 -04:00
|
|
|
case action.to_s
|
|
|
|
when 'add_key'
|
2020-03-12 08:09:17 -04:00
|
|
|
authorized_keys.add_key(*args)
|
2020-03-23 14:09:25 -04:00
|
|
|
when 'remove_key'
|
2020-03-12 08:09:17 -04:00
|
|
|
authorized_keys.remove_key(*args)
|
2020-03-23 14:09:25 -04:00
|
|
|
else
|
|
|
|
raise "Unknown action: #{action.inspect}"
|
2020-03-12 08:09:17 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def authorized_keys
|
|
|
|
@authorized_keys ||= Gitlab::AuthorizedKeys.new
|
|
|
|
end
|
|
|
|
end
|