BigW Consortium Gitlab

project_import_data.rb 743 Bytes
Newer Older
1 2 3 4
require 'carrierwave/orm/activerecord'

class ProjectImportData < ActiveRecord::Base
  belongs_to :project
5 6 7 8
  attr_encrypted :credentials,
                 key: Gitlab::Application.secrets.db_key_base,
                 marshal: true,
                 encode: true,
9
                 mode: :per_attribute_iv_and_salt,
10
                 insecure_mode: true,
11
                 algorithm: 'aes-256-cbc'
12

13
  serialize :data, JSON # rubocop:disable Cop/ActiverecordSerialize
14 15

  validates :project, presence: true
James Lopez committed
16

17 18 19
  before_validation :symbolize_credentials

  def symbolize_credentials
20
    # bang doesn't work here - attr_encrypted makes it not to work
21
    self.credentials = self.credentials.deep_symbolize_keys unless self.credentials.blank?
James Lopez committed
22
  end
23
end