Sha256: e52b6868a3589dcecb1e909a69e5eb59675f7660b1079fcc53136e8340e11ba6

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module AttrKeyring
  require "active_record"
  require "openssl"
  require "digest/sha1"

  require "attr_keyring/version"
  require "attr_keyring/active_record"
  require "attr_keyring/keyring"
  require "attr_keyring/key"
  require "attr_keyring/encryptor/aes"
  require "attr_keyring/encryptor/aes_128_cbc"
  require "attr_keyring/encryptor/aes_256_cbc"

  UnknownKey = Class.new(StandardError)
  InvalidSecret = Class.new(StandardError)

  def self.included(target)
    target.class_eval do
      extend AttrKeyring::ActiveRecord::ClassMethods
      include AttrKeyring::ActiveRecord::InstanceMethods

      class << self
        attr_accessor :keyring_attrs
        attr_accessor :keyring

        def inherited(subclass)
          super

          subclass.keyring_attrs = []
          subclass.keyring = Keyring.new({})
        end
      end

      cattr_accessor :keyring_column_name, default: "keyring_id"
      self.keyring_attrs = []
      self.keyring = Keyring.new({})

      before_save :migrate_to_latest_encryption_key
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
attr_keyring-0.2.2 lib/attr_keyring.rb