2018-11-21 05:46:36 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module BackgroundMigration
|
|
|
|
module Models
|
|
|
|
module EncryptColumns
|
|
|
|
# This model is shared between synchronous and background migrations to
|
|
|
|
# encrypt the `runners_token` column in `application_settings` table.
|
|
|
|
#
|
|
|
|
class Settings < ActiveRecord::Base
|
|
|
|
include ::EachBatch
|
2018-11-28 05:43:17 -05:00
|
|
|
include ::CacheableAttributes
|
2018-11-21 05:46:36 -05:00
|
|
|
|
|
|
|
self.table_name = 'application_settings'
|
|
|
|
self.inheritance_column = :_type_disabled
|
|
|
|
|
2018-11-28 05:43:17 -05:00
|
|
|
after_commit do
|
2018-12-03 07:21:36 -05:00
|
|
|
::ApplicationSetting.expire
|
2018-11-28 05:43:17 -05:00
|
|
|
end
|
|
|
|
|
2018-11-23 05:55:38 -05:00
|
|
|
def runners_registration_token=(value)
|
|
|
|
self.runners_registration_token_encrypted =
|
2018-11-21 05:46:36 -05:00
|
|
|
::Gitlab::CryptoHelper.aes256_gcm_encrypt(value)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.encrypted_attributes
|
2018-11-23 05:55:38 -05:00
|
|
|
{
|
|
|
|
runners_registration_token: {
|
|
|
|
attribute: :runners_registration_token_encrypted
|
|
|
|
}
|
|
|
|
}
|
2018-11-21 05:46:36 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|