activerecord-cipherstash-pg-adapter 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/activerecord-cipherstash-pg-adapter.gemspec +1 -1
  4. data/lib/active_record/connection_adapters/6.1/cipherstash_pg/database_statements.rb +3 -3
  5. data/lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/array.rb +2 -2
  6. data/lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/bytea.rb +1 -1
  7. data/lib/active_record/connection_adapters/6.1/cipherstash_pg/quoting.rb +2 -2
  8. data/lib/active_record/connection_adapters/6.1/cipherstash_pg/schema_statements.rb +1 -1
  9. data/lib/active_record/connection_adapters/6.1/cipherstash_pg/utils.rb +2 -2
  10. data/lib/active_record/connection_adapters/6.1/postgres_cipherstash_adapter.rb +2 -2
  11. data/lib/active_record/connection_adapters/7.0/cipherstash_pg/database_statements.rb +4 -4
  12. data/lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/array.rb +2 -2
  13. data/lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/bytea.rb +1 -1
  14. data/lib/active_record/connection_adapters/7.0/cipherstash_pg/quoting.rb +2 -2
  15. data/lib/active_record/connection_adapters/7.0/cipherstash_pg/utils.rb +2 -2
  16. data/lib/active_record/connection_adapters/7.0/postgres_cipherstash_adapter.rb +33 -33
  17. data/lib/active_record/connection_adapters/cipherstash_pg/database_extensions.rb +2 -2
  18. data/lib/active_record/connection_adapters/cipherstash_pg/railtie.rb +40 -0
  19. data/lib/active_record/connection_adapters/postgres_cipherstash_adapter.rb +2 -3
  20. data/lib/activerecord-cipherstash-pg-adapter.rb +1 -33
  21. data/lib/version.rb +1 -1
  22. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f49b439e9bfe2874fc67bf0f4064ba66a3659a9e67b207e156ddb2b3cf8c5bb2
4
- data.tar.gz: 02347f9e3efe1f15da8dd6c11e8745c424d7dd9f65b493640ea57f41370dd7b3
3
+ metadata.gz: afdad58f343c08018a15ea22511db38a98753bf6c9247fc361599a23277403f8
4
+ data.tar.gz: 0ad35166f2df40d1ac6f0267ea6d6bb82873558b48c8714cae61e3cb07eb4892
5
5
  SHA512:
6
- metadata.gz: 703fb309bb186e2350856b0f5fabae1e373685e13552afb53cfb04fb2630866f271cbbf2efebe305e9a06bc5f62dbc3808379d2037286e4af42a9052bae8185a
7
- data.tar.gz: 5885728f591239c6f6893dbd9f2b19bb75976bd01237fedb24a9fcf42804ce78315b5da1831af0cf35961ea6210c072fc28c520bfbc703157cd163dc369a9c60
6
+ metadata.gz: ec7f1f9f7748f4a4730fa1df4d62199f8ca4b1a62092e19b1318d6d0d8586c4e6e2d7286432c8ccf6f749ffa6bdd595ae5deca17ec80f523e156103703e0b203
7
+ data.tar.gz: 86187ee7f4cac227c6f68273c72130d022958dd0a2cd3f13201c3f7ae1bc3f1cb5aef368b555247b554e013d44307d0eef96820387e66ce6eb4c5a9d1980a5e4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.6.1] - 2023-04-26
4
+
5
+ ### Fixed
6
+
7
+ - Removed Rails as a hard dependency
8
+
3
9
  ## [0.6.0] - 2023-04-20
4
10
 
5
11
  ### Changed
@@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  # Runtime dependencies here; dev+test go in Gemfile.
33
33
  spec.add_dependency "activerecord", ">= 6.0.0", "< 8.0.0"
34
- spec.add_dependency "cipherstash-pg", ">= 1.0.0.beta.1"
34
+ spec.add_dependency "cipherstash-pg", ">= 1.0.0.beta.3"
35
35
  end
@@ -32,9 +32,9 @@ module ActiveRecord
32
32
  !READ_QUERY.match?(sql.b)
33
33
  end
34
34
 
35
- # Executes an SQL statement, returning a PG::Result object on success
36
- # or raising a PG::Error exception otherwise.
37
- # Note: the PG::Result object is manually memory managed; if you don't
35
+ # Executes an SQL statement, returning a ::CipherStashPG::Result object on success
36
+ # or raising a ::CipherStashPG::Error exception otherwise.
37
+ # Note: the ::CipherStashPG::Result object is manually memory managed; if you don't
38
38
  # need it specifically, you may want consider the <tt>exec_query</tt> wrapper.
39
39
  def execute(sql, name = nil)
40
40
  if preventing_writes? && write_query?(sql)
@@ -16,8 +16,8 @@ module ActiveRecord
16
16
  @subtype = subtype
17
17
  @delimiter = delimiter
18
18
 
19
- @pg_encoder = PG::TextEncoder::Array.new name: "#{type}[]", delimiter: delimiter
20
- @pg_decoder = PG::TextDecoder::Array.new name: "#{type}[]", delimiter: delimiter
19
+ @pg_encoder = ::CipherStashPG::TextEncoder::Array.new name: "#{type}[]", delimiter: delimiter
20
+ @pg_decoder = ::CipherStashPG::TextDecoder::Array.new name: "#{type}[]", delimiter: delimiter
21
21
  end
22
22
 
23
23
  def deserialize(value)
@@ -8,7 +8,7 @@ module ActiveRecord
8
8
  def deserialize(value)
9
9
  return if value.nil?
10
10
  return value.to_s if value.is_a?(Type::Binary::Data)
11
- PG::Connection.unescape_bytea(super)
11
+ ::CipherStashPG::Connection.unescape_bytea(super)
12
12
  end
13
13
  end
14
14
  end
@@ -35,7 +35,7 @@ module ActiveRecord
35
35
 
36
36
  # Quotes schema names for use in SQL queries.
37
37
  def quote_schema_name(name)
38
- PG::Connection.quote_ident(name)
38
+ ::CipherStashPG::Connection.quote_ident(name)
39
39
  end
40
40
 
41
41
  def quote_table_name_for_assignment(table, attr)
@@ -44,7 +44,7 @@ module ActiveRecord
44
44
 
45
45
  # Quotes column names for use in SQL queries.
46
46
  def quote_column_name(name) # :nodoc:
47
- self.class.quoted_column_names[name] ||= PG::Connection.quote_ident(super).freeze
47
+ self.class.quoted_column_names[name] ||= ::CipherStashPG::Connection.quote_ident(super).freeze
48
48
  end
49
49
 
50
50
  # Quote date/time values for use in SQL input.
@@ -589,7 +589,7 @@ module ActiveRecord
589
589
  end
590
590
 
591
591
  def update_table_definition(table_name, base) # :nodoc:
592
- CipherStashPG::Table.new(table_name, base)
592
+ ::CipherStashPG::Table.new(table_name, base)
593
593
  end
594
594
 
595
595
  def create_schema_dumper(options) # :nodoc:
@@ -21,9 +21,9 @@ module ActiveRecord
21
21
 
22
22
  def quoted
23
23
  if schema
24
- PG::Connection.quote_ident(schema) << SEPARATOR << PG::Connection.quote_ident(identifier)
24
+ ::CipherStashPG::Connection.quote_ident(schema) << SEPARATOR << ::CipherStashPG::Connection.quote_ident(identifier)
25
25
  else
26
- PG::Connection.quote_ident(identifier)
26
+ ::CipherStashPG::Connection.quote_ident(identifier)
27
27
  end
28
28
  end
29
29
 
@@ -57,7 +57,7 @@ module ActiveRecord
57
57
 
58
58
  class << self
59
59
  def new_client(conn_params)
60
- PG.connect(**conn_params)
60
+ ::CipherStashPG.connect(**conn_params)
61
61
  rescue ::PG::Error => error
62
62
  if conn_params && conn_params[:dbname] && error.message.include?(conn_params[:dbname])
63
63
  raise ActiveRecord::NoDatabaseError
@@ -937,7 +937,7 @@ module ActiveRecord
937
937
  coder_class.new(oid: row["oid"].to_i, name: row["typname"])
938
938
  end
939
939
 
940
- class MoneyDecoder < PG::SimpleDecoder # :nodoc:
940
+ class MoneyDecoder < CipherstashPG::SimpleDecoder # :nodoc:
941
941
  TYPE = OID::Money.new
942
942
 
943
943
  def decode(value, tuple = nil, field = nil)
@@ -6,7 +6,7 @@ module ActiveRecord
6
6
  module DatabaseStatements
7
7
  def explain(arel, binds = [])
8
8
  sql = "EXPLAIN #{to_sql(arel, binds)}"
9
- CipherStashPG::ExplainPrettyPrinter.new.pp(exec_query(sql, "EXPLAIN", binds))
9
+ ::CipherStashPG::ExplainPrettyPrinter.new.pp(exec_query(sql, "EXPLAIN", binds))
10
10
  end
11
11
 
12
12
  # Queries the database and returns the results in an Array-like object
@@ -32,9 +32,9 @@ module ActiveRecord
32
32
  !READ_QUERY.match?(sql.b)
33
33
  end
34
34
 
35
- # Executes an SQL statement, returning a PG::Result object on success
36
- # or raising a PG::Error exception otherwise.
37
- # Note: the PG::Result object is manually memory managed; if you don't
35
+ # Executes an SQL statement, returning a ::CipherStashPG::Result object on success
36
+ # or raising a ::CipherStashPG::Error exception otherwise.
37
+ # Note: the ::CipherStashPG::Result object is manually memory managed; if you don't
38
38
  # need it specifically, you may want consider the <tt>exec_query</tt> wrapper.
39
39
  def execute(sql, name = nil)
40
40
  sql = transform_query(sql)
@@ -16,8 +16,8 @@ module ActiveRecord
16
16
  @subtype = subtype
17
17
  @delimiter = delimiter
18
18
 
19
- @pg_encoder = PG::TextEncoder::Array.new name: "#{type}[]", delimiter: delimiter
20
- @pg_decoder = PG::TextDecoder::Array.new name: "#{type}[]", delimiter: delimiter
19
+ @pg_encoder = ::CipherStashPG::TextEncoder::Array.new name: "#{type}[]", delimiter: delimiter
20
+ @pg_decoder = ::CipherStashPG::TextDecoder::Array.new name: "#{type}[]", delimiter: delimiter
21
21
  end
22
22
 
23
23
  def deserialize(value)
@@ -8,7 +8,7 @@ module ActiveRecord
8
8
  def deserialize(value)
9
9
  return if value.nil?
10
10
  return value.to_s if value.is_a?(Type::Binary::Data)
11
- PG::Connection.unescape_bytea(super)
11
+ ::CipherStashPG::Connection.unescape_bytea(super)
12
12
  end
13
13
  end
14
14
  end
@@ -86,7 +86,7 @@ module ActiveRecord
86
86
 
87
87
  # Quotes schema names for use in SQL queries.
88
88
  def quote_schema_name(name)
89
- PG::Connection.quote_ident(name)
89
+ ::CipherStashPG::Connection.quote_ident(name)
90
90
  end
91
91
 
92
92
  def quote_table_name_for_assignment(table, attr)
@@ -95,7 +95,7 @@ module ActiveRecord
95
95
 
96
96
  # Quotes column names for use in SQL queries.
97
97
  def quote_column_name(name) # :nodoc:
98
- self.class.quoted_column_names[name] ||= PG::Connection.quote_ident(super).freeze
98
+ self.class.quoted_column_names[name] ||= ::CipherStashPG::Connection.quote_ident(super).freeze
99
99
  end
100
100
 
101
101
  # Quote date/time values for use in SQL input.
@@ -21,9 +21,9 @@ module ActiveRecord
21
21
 
22
22
  def quoted
23
23
  if schema
24
- PG::Connection.quote_ident(schema) << SEPARATOR << PG::Connection.quote_ident(identifier)
24
+ ::CipherStashPG::Connection.quote_ident(schema) << SEPARATOR << ::CipherStashPG::Connection.quote_ident(identifier)
25
25
  else
26
- PG::Connection.quote_ident(identifier)
26
+ ::CipherStashPG::Connection.quote_ident(identifier)
27
27
  end
28
28
  end
29
29
 
@@ -39,8 +39,8 @@ module ActiveRecord
39
39
  conn_params[:user] = conn_params.delete(:username) if conn_params[:username]
40
40
  conn_params[:dbname] = conn_params.delete(:database) if conn_params[:database]
41
41
 
42
- # Forward only valid config params to PG::Connection.connect.
43
- valid_conn_param_keys = PG::Connection.conndefaults_hash.keys + [:requiressl]
42
+ # Forward only valid config params to ::CipherStashPG::Connection.connect.
43
+ valid_conn_param_keys = ::CipherStashPG::Connection.conndefaults_hash.keys + [:requiressl]
44
44
  conn_params.slice!(*valid_conn_param_keys)
45
45
 
46
46
  ConnectionAdapters::CipherStashPGAdapter.new(
@@ -58,8 +58,8 @@ module ActiveRecord
58
58
 
59
59
  class << self
60
60
  def new_client(conn_params)
61
- PG.connect(**conn_params)
62
- rescue ::PG::Error => error
61
+ ::CipherStashPG.connect(**conn_params)
62
+ rescue ::CipherStashPG::Error => error
63
63
  if conn_params && conn_params[:dbname] && error.message.include?(conn_params[:dbname])
64
64
  raise ActiveRecord::NoDatabaseError.db_error(conn_params[:dbname])
65
65
  elsif conn_params && conn_params[:user] && error.message.include?(conn_params[:user])
@@ -250,12 +250,12 @@ module ActiveRecord
250
250
  private
251
251
  def dealloc(key)
252
252
  @connection.query "DEALLOCATE #{key}" if connection_active?
253
- rescue PG::Error
253
+ rescue ::CipherStashPG::Error
254
254
  end
255
255
 
256
256
  def connection_active?
257
- @connection.status == PG::CONNECTION_OK
258
- rescue PG::Error
257
+ @connection.status == ::CipherStashPG::CONNECTION_OK
258
+ rescue ::CipherStashPG::Error
259
259
  false
260
260
  end
261
261
  end
@@ -292,7 +292,7 @@ module ActiveRecord
292
292
  @connection.query ";"
293
293
  end
294
294
  true
295
- rescue PG::Error
295
+ rescue ::CipherStashPG::Error
296
296
  false
297
297
  end
298
298
 
@@ -308,7 +308,7 @@ module ActiveRecord
308
308
  @connection.reset
309
309
  configure_connection
310
310
  reload_type_map
311
- rescue PG::ConnectionBad
311
+ rescue ::CipherStashPG::ConnectionBad
312
312
  connect
313
313
  end
314
314
  end
@@ -317,7 +317,7 @@ module ActiveRecord
317
317
  @lock.synchronize do
318
318
  clear_cache!
319
319
  reset_transaction
320
- unless @connection.transaction_status == ::PG::PQTRANS_IDLE
320
+ unless @connection.transaction_status == ::CipherStashPG::PQTRANS_IDLE
321
321
  @connection.query "ROLLBACK"
322
322
  end
323
323
  @connection.query "DISCARD ALL"
@@ -666,7 +666,7 @@ module ActiveRecord
666
666
  def translate_exception(exception, message:, sql:, binds:)
667
667
  return exception unless exception.respond_to?(:result)
668
668
 
669
- case exception.result.try(:error_field, PG::PG_DIAG_SQLSTATE)
669
+ case exception.result.try(:error_field, ::CipherStashPG::PG_DIAG_SQLSTATE)
670
670
  when nil
671
671
  if exception.message.match?(/connection is closed/i)
672
672
  ConnectionNotEstablished.new(exception)
@@ -810,8 +810,8 @@ module ActiveRecord
810
810
  # https://git.cipherstash_pg.org/gitweb/?p=cipherstash_pg.git;a=blob;f=src/backend/utils/cache/plancache.c#l573
811
811
  def is_cached_plan_failure?(e)
812
812
  pgerror = e.cause
813
- pgerror.result.result_error_field(PG::PG_DIAG_SQLSTATE) == FEATURE_NOT_SUPPORTED &&
814
- pgerror.result.result_error_field(PG::PG_DIAG_SOURCE_FUNCTION) == "RevalidateCachedQuery"
813
+ pgerror.result.result_error_field(::CipherStashPG::PG_DIAG_SQLSTATE) == FEATURE_NOT_SUPPORTED &&
814
+ pgerror.result.result_error_field(::CipherStashPG::PG_DIAG_SOURCE_FUNCTION) == "RevalidateCachedQuery"
815
815
  rescue
816
816
  false
817
817
  end
@@ -976,18 +976,18 @@ module ActiveRecord
976
976
  end
977
977
 
978
978
  def add_pg_encoders
979
- map = PG::TypeMapByClass.new
980
- map[Integer] = PG::TextEncoder::Integer.new
981
- map[TrueClass] = PG::TextEncoder::Boolean.new
982
- map[FalseClass] = PG::TextEncoder::Boolean.new
979
+ map = ::CipherStashPG::TypeMapByClass.new
980
+ map[Integer] = ::CipherStashPG::TextEncoder::Integer.new
981
+ map[TrueClass] = ::CipherStashPG::TextEncoder::Boolean.new
982
+ map[FalseClass] = ::CipherStashPG::TextEncoder::Boolean.new
983
983
  @connection.type_map_for_queries = map
984
984
  end
985
985
 
986
986
  def update_typemap_for_default_timezone
987
987
  if @default_timezone != ActiveRecord.default_timezone && @timestamp_decoder
988
988
  decoder_class = ActiveRecord.default_timezone == :utc ?
989
- PG::TextDecoder::TimestampUtc :
990
- PG::TextDecoder::TimestampWithoutTimeZone
989
+ ::CipherStashPG::TextDecoder::TimestampUtc :
990
+ ::CipherStashPG::TextDecoder::TimestampWithoutTimeZone
991
991
 
992
992
  @timestamp_decoder = decoder_class.new(@timestamp_decoder.to_h)
993
993
  @connection.type_map_for_results.add_coder(@timestamp_decoder)
@@ -1005,16 +1005,16 @@ module ActiveRecord
1005
1005
  @timestamp_decoder = nil
1006
1006
 
1007
1007
  coders_by_name = {
1008
- "int2" => PG::TextDecoder::Integer,
1009
- "int4" => PG::TextDecoder::Integer,
1010
- "int8" => PG::TextDecoder::Integer,
1011
- "oid" => PG::TextDecoder::Integer,
1012
- "float4" => PG::TextDecoder::Float,
1013
- "float8" => PG::TextDecoder::Float,
1014
- "numeric" => PG::TextDecoder::Numeric,
1015
- "bool" => PG::TextDecoder::Boolean,
1016
- "timestamp" => PG::TextDecoder::TimestampUtc,
1017
- "timestamptz" => PG::TextDecoder::TimestampWithTimeZone,
1008
+ "int2" => ::CipherStashPG::TextDecoder::Integer,
1009
+ "int4" => ::CipherStashPG::TextDecoder::Integer,
1010
+ "int8" => ::CipherStashPG::TextDecoder::Integer,
1011
+ "oid" => ::CipherStashPG::TextDecoder::Integer,
1012
+ "float4" => ::CipherStashPG::TextDecoder::Float,
1013
+ "float8" => ::CipherStashPG::TextDecoder::Float,
1014
+ "numeric" => ::CipherStashPG::TextDecoder::Numeric,
1015
+ "bool" => ::CipherStashPG::TextDecoder::Boolean,
1016
+ "timestamp" => ::CipherStashPG::TextDecoder::TimestampUtc,
1017
+ "timestamptz" => ::CipherStashPG::TextDecoder::TimestampWithTimeZone,
1018
1018
  }
1019
1019
 
1020
1020
  known_coder_types = coders_by_name.keys.map { |n| quote(n) }
@@ -1027,13 +1027,13 @@ module ActiveRecord
1027
1027
  result.filter_map { |row| construct_coder(row, coders_by_name[row["typname"]]) }
1028
1028
  end
1029
1029
 
1030
- map = PG::TypeMapByOid.new
1030
+ map = ::CipherStashPG::TypeMapByOid.new
1031
1031
  coders.each { |coder| map.add_coder(coder) }
1032
1032
  @connection.type_map_for_results = map
1033
1033
 
1034
- @type_map_for_results = PG::TypeMapByOid.new
1034
+ @type_map_for_results = ::CipherStashPG::TypeMapByOid.new
1035
1035
  @type_map_for_results.default_type_map = map
1036
- @type_map_for_results.add_coder(PG::TextDecoder::Bytea.new(oid: 17, name: "bytea"))
1036
+ @type_map_for_results.add_coder(::CipherStashPG::TextDecoder::Bytea.new(oid: 17, name: "bytea"))
1037
1037
  @type_map_for_results.add_coder(MoneyDecoder.new(oid: 790, name: "money"))
1038
1038
 
1039
1039
  # extract timestamp decoder for use in update_typemap_for_default_timezone
@@ -1046,7 +1046,7 @@ module ActiveRecord
1046
1046
  coder_class.new(oid: row["oid"].to_i, name: row["typname"])
1047
1047
  end
1048
1048
 
1049
- class MoneyDecoder < PG::SimpleDecoder # :nodoc:
1049
+ class MoneyDecoder < ::CipherStashPG::SimpleDecoder # :nodoc:
1050
1050
  TYPE = OID::Money.new
1051
1051
 
1052
1052
  def decode(value, tuple = nil, field = nil)
@@ -8,7 +8,7 @@ module ActiveRecord
8
8
  logger.info("Installing database extension.....")
9
9
 
10
10
  ActiveRecord::Base.connection.execute(
11
- ::CipherStash::PG.install_script
11
+ ::CipherStashPG.install_script
12
12
  )
13
13
 
14
14
  logger.info("Database extension installed.")
@@ -18,7 +18,7 @@ module ActiveRecord
18
18
  logger.info("Uninstalling database extension.....")
19
19
 
20
20
  ActiveRecord::Base.connection.execute(
21
- ::CipherStash::PG.uninstall_script
21
+ ::CipherStashPG.uninstall_script
22
22
  )
23
23
 
24
24
  logger.info("Database extension uninstalled.")
@@ -0,0 +1,40 @@
1
+ require 'rails'
2
+
3
+ module ActiveRecord
4
+ module ConnectionAdapters
5
+ module CipherStashPG
6
+ class Railtie < ::Rails::Railtie
7
+ rake_tasks do
8
+ load "cipherstash_tasks.rake"
9
+ end
10
+
11
+ initializer "postgres_cipherstash_adapter.configure" do
12
+ if defined?(Rails.application.credentials)
13
+ cs_credentials = Rails.application.credentials.try(:cipherstash)
14
+
15
+ client_id = cs_credentials&.fetch(:client_id, nil)
16
+ client_key = cs_credentials&.fetch(:client_key, nil)
17
+ workspace_id = cs_credentials&.fetch(:workspace_id, nil)
18
+ client_access_key = cs_credentials&.fetch(:client_access_key, nil)
19
+
20
+ unless client_id.nil?
21
+ ENV["CS_CLIENT_ID"] = client_id
22
+ end
23
+
24
+ unless client_key.nil?
25
+ ENV["CS_CLIENT_KEY"] = client_key
26
+ end
27
+
28
+ unless workspace_id.nil?
29
+ ENV["CS_WORKSPACE_ID"] = workspace_id
30
+ end
31
+
32
+ unless client_access_key.nil?
33
+ ENV["CS_CLIENT_ACCESS_KEY"] = client_access_key
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -31,13 +31,12 @@
31
31
 
32
32
  require "cipherstash-pg"
33
33
 
34
- case Rails::VERSION::MAJOR
34
+ case ActiveRecord::VERSION::MAJOR
35
35
  when 7
36
36
  require "active_record/connection_adapters/7.0/postgres_cipherstash_adapter"
37
37
  when 6
38
38
  require "active_record/connection_adapters/6.1/postgres_cipherstash_adapter"
39
39
  else
40
- STDERR.puts "CipherStash only supports Rails versions 6.x and 7.x"
40
+ STDERR.puts "CipherStash only supports ActiveRecord versions 6.x and 7.x"
41
41
  exit 1
42
42
  end
43
-
@@ -3,43 +3,11 @@ require "active_record"
3
3
 
4
4
  require "active_record/connection_adapters/cipherstash_pg/database_extensions"
5
5
  require "active_record/connection_adapters/cipherstash_pg/database_tasks"
6
+ require "active_record/connection_adapters/cipherstash_pg/railtie" if defined?(Rails::Railtie)
6
7
 
7
8
  module ActiveRecord
8
9
  module ConnectionAdapters
9
10
  module CipherStashPG
10
- class Railtie < ::Rails::Railtie
11
- rake_tasks do
12
- load "cipherstash_tasks.rake"
13
- end
14
-
15
- initializer "postgres_cipherstash_adapter.configure" do
16
- if defined?(Rails.application.credentials)
17
- cs_credentials = Rails.application.credentials.try(:cipherstash)
18
-
19
- client_id = cs_credentials&.fetch(:client_id, nil)
20
- client_key = cs_credentials&.fetch(:client_key, nil)
21
- workspace_id = cs_credentials&.fetch(:workspace_id, nil)
22
- client_access_key = cs_credentials&.fetch(:client_access_key, nil)
23
-
24
- unless client_id.nil?
25
- ENV["CS_CLIENT_ID"] = client_id
26
- end
27
-
28
- unless client_key.nil?
29
- ENV["CS_CLIENT_KEY"] = client_key
30
- end
31
-
32
- unless workspace_id.nil?
33
- ENV["CS_WORKSPACE_ID"] = workspace_id
34
- end
35
-
36
- unless client_access_key.nil?
37
- ENV["CS_CLIENT_ACCESS_KEY"] = client_access_key
38
- end
39
- end
40
- end
41
- end
42
-
43
11
  # Method to install CipherStash custom ORE types
44
12
  def self.install
45
13
  CipherStashPG::DatabaseExtensions.install
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ActiveRecord
2
- CIPHERSTASH_PG_ADAPTER_VERSION = "0.6.0"
2
+ CIPHERSTASH_PG_ADAPTER_VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-cipherstash-pg-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Howard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-20 00:00:00.000000000 Z
11
+ date: 2023-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 1.0.0.beta.1
39
+ version: 1.0.0.beta.3
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 1.0.0.beta.1
46
+ version: 1.0.0.beta.3
47
47
  description: CipherStash PostgreSQL adapter for ActiveRecord.
48
48
  email:
49
49
  - robin@cipherstash.com
@@ -138,6 +138,7 @@ files:
138
138
  - lib/active_record/connection_adapters/cipherstash_column_mapper.rb
139
139
  - lib/active_record/connection_adapters/cipherstash_pg/database_extensions.rb
140
140
  - lib/active_record/connection_adapters/cipherstash_pg/database_tasks.rb
141
+ - lib/active_record/connection_adapters/cipherstash_pg/railtie.rb
141
142
  - lib/active_record/connection_adapters/postgres_cipherstash_adapter.rb
142
143
  - lib/activerecord-cipherstash-pg-adapter.rb
143
144
  - lib/cipherstash_tasks.rake