自动扩展加密参数以支持查询加密和未加密的数据
Active Record Encryption 支持使用确定性属性查询数据库。例如
Contact.find_by(email_address: "jorge@hey.com")
值“jorge@hey.com”将被自动加密以执行查询。但是,在数据加密过程中存在一个问题。那时,您将需要这些查询为
Contact.find_by(email_address: [ "jorge@hey.com", "<encrypted jorge@hey.com>" ])
此补丁 ActiveRecord 以自动支持此功能。它解决了
-
ActiveRecord::Base- 用于Contact.find_by_email_address(...) -
ActiveRecord::Relation- 用于Contact.internal.find_by_email_address(...)
如果 `config.active_record.encryption.extend_queries` 为 `true`,则会包含此模块。
命名空间
- 模块 ActiveRecord::Encryption::ExtendedDeterministicQueries::CoreQueries
- 模块 ActiveRecord::Encryption::ExtendedDeterministicQueries::ExtendedEncryptableType
- 模块 ActiveRecord::Encryption::ExtendedDeterministicQueries::RelationQueries
- 类 ActiveRecord::Encryption::ExtendedDeterministicQueries::AdditionalValue
方法
类公共方法
install_support() 链接
源码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/encryption/extended_deterministic_queries.rb, line 24 def self.install_support # ActiveRecord::Base relies on ActiveRecord::Relation (ActiveRecord::QueryMethods) but it does # some prepared statements caching. That's why we need to intercept +ActiveRecord::Base+ as soon # as it's invoked (so that the proper prepared statement is cached). ActiveRecord::Relation.prepend(RelationQueries) ActiveRecord::Base.include(CoreQueries) ActiveRecord::Encryption::EncryptedAttributeType.prepend(ExtendedEncryptableType) end