active_record-pgcrypto 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/main.workflow +17 -4
- data/Dockerfile +1 -1
- data/active_record-pgcrypto.gemspec +3 -1
- data/lib/active_record/pgcrypto.rb +3 -2
- data/lib/active_record/pgcrypto/symmetric_coder.rb +15 -12
- data/lib/active_record/pgcrypto/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68b93cced1e27c13c2bf95d0731a0f7998ce35b6d481c2b38235cd407697e601
|
4
|
+
data.tar.gz: b4e89c6612d5d67661fb4ef896c468c8ba46c2ab4e5ab7aed29c178fe7a65633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f135dffa6f20c0623f0fb7dd2804651f5d930eb75958b5a1b69e7ab520a12326aebe35ac2cfdb3a31f52d3057d8d91457402b75ccb548d91f9c8bccd0512049e
|
7
|
+
data.tar.gz: 9010ddbc616b30098531785d76e5429cf704755edaf49d0313becde5560dcd3e1ebebbea49725e0f372e1f65eac6e9a1f49f00a2117aaf6b658180445f6e2295
|
data/.github/main.workflow
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
workflow "Docs/Tests" {
|
2
2
|
on = "push"
|
3
3
|
resolves = [
|
4
|
-
"
|
5
|
-
"Runs the linters and tests"
|
4
|
+
"Runs the linters and tests (Rails 4)",
|
5
|
+
"Runs the linters and tests (Rails 5)",
|
6
|
+
"Runs the linters and tests (Rails 6)"
|
6
7
|
]
|
7
8
|
}
|
8
9
|
|
@@ -11,8 +12,20 @@ action "Builds the Docker image" {
|
|
11
12
|
args = "build -f Dockerfile -t active_record-pgcrypto/ci:$GITHUB_SHA ."
|
12
13
|
}
|
13
14
|
|
14
|
-
action "Runs the linters and tests" {
|
15
|
+
action "Runs the linters and tests (Rails 4)" {
|
15
16
|
uses = "actions/docker/cli@master"
|
16
17
|
needs = ["Builds the Docker image"]
|
17
|
-
args = "run active_record-pgcrypto/ci:$GITHUB_SHA"
|
18
|
+
args = "run -e RAILS_VERSION='~> 4' active_record-pgcrypto/ci:$GITHUB_SHA"
|
19
|
+
}
|
20
|
+
|
21
|
+
action "Runs the linters and tests (Rails 5)" {
|
22
|
+
uses = "actions/docker/cli@master"
|
23
|
+
needs = ["Builds the Docker image"]
|
24
|
+
args = "run -e RAILS_VERSION='~> 5' active_record-pgcrypto/ci:$GITHUB_SHA"
|
25
|
+
}
|
26
|
+
|
27
|
+
action "Runs the linters and tests (Rails 6)" {
|
28
|
+
uses = "actions/docker/cli@master"
|
29
|
+
needs = ["Builds the Docker image"]
|
30
|
+
args = "run -e RAILS_VERSION='~> 6.0.0.rc1' active_record-pgcrypto/ci:$GITHUB_SHA"
|
18
31
|
}
|
data/Dockerfile
CHANGED
@@ -14,4 +14,4 @@ ENV DATABASE_URL=postgresql://postgres@localhost/postgres?pool=5
|
|
14
14
|
|
15
15
|
ENTRYPOINT []
|
16
16
|
|
17
|
-
CMD ["sh", "-c", "(nohup /docker-entrypoint.sh postgres > /dev/null &) && sleep 3 && bundle exec rake"]
|
17
|
+
CMD ["sh", "-c", "(nohup /docker-entrypoint.sh postgres > /dev/null &) && sleep 3 && bundle install && bundle exec rake"]
|
@@ -21,9 +21,11 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_dependency 'activerecord', ENV['RAILS_VERSION']
|
23
23
|
|
24
|
+
pg_version = '< 1' if ENV['RAILS_VERSION'].to_s.split(' ').last.to_i == 4
|
25
|
+
|
24
26
|
spec.add_development_dependency 'bundler'
|
25
27
|
spec.add_development_dependency 'ffaker'
|
26
|
-
spec.add_development_dependency 'pg'
|
28
|
+
spec.add_development_dependency 'pg', pg_version
|
27
29
|
spec.add_development_dependency 'rake'
|
28
30
|
spec.add_development_dependency 'rspec'
|
29
31
|
spec.add_development_dependency 'rubocop-performance'
|
@@ -1,5 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'active_support'
|
2
2
|
require 'active_record/log_subscriber'
|
3
|
+
require 'active_record/pgcrypto/version'
|
3
4
|
require 'active_record/pgcrypto/symmetric_coder'
|
4
5
|
require 'active_record/pgcrypto/log_subscriber'
|
5
6
|
|
@@ -10,7 +11,7 @@ module ActiveRecord
|
|
10
11
|
#
|
11
12
|
# @return [NilClass]
|
12
13
|
def self.enable_log_subscriber!
|
13
|
-
ActiveRecord::LogSubscriber.prepend(
|
14
|
+
::ActiveRecord::LogSubscriber.prepend(LogSubscriber)
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
@@ -2,17 +2,15 @@ module ActiveRecord
|
|
2
2
|
module PGCrypto
|
3
3
|
# PGCrypto symmetric encryption/decryption coder for attribute serialization
|
4
4
|
module SymmetricCoder
|
5
|
-
mattr_accessor :pgcrypto_key
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
default: Encoding.find(ENV['PGCRYPTO_ENCODING'] || 'utf-8')
|
15
|
-
)
|
5
|
+
mattr_accessor :pgcrypto_key do
|
6
|
+
ENV['PGCRYPTO_SYM_KEY']
|
7
|
+
end
|
8
|
+
mattr_accessor :pgcrypto_options do
|
9
|
+
ENV['PGCRYPTO_SYM_OPTIONS'] || 'cipher-algo=aes256, unicode-mode=1'
|
10
|
+
end
|
11
|
+
mattr_accessor :pgcrypto_encoding do
|
12
|
+
Encoding.find(ENV['PGCRYPTO_ENCODING'] || 'utf-8')
|
13
|
+
end
|
16
14
|
|
17
15
|
# Decrypts the requested value
|
18
16
|
#
|
@@ -73,8 +71,13 @@ module ActiveRecord
|
|
73
71
|
#
|
74
72
|
# @return [String] the first returned value
|
75
73
|
def self.arel_query(arel_nodes)
|
76
|
-
|
74
|
+
sel_manager = Arel::SelectManager.new(nil)
|
75
|
+
|
76
|
+
if ::ActiveRecord::VERSION::MAJOR == 4
|
77
|
+
sel_manager = Arel::SelectManager.new(::ActiveRecord::Base)
|
78
|
+
end
|
77
79
|
|
80
|
+
query = sel_manager.project(arel_nodes).to_sql
|
78
81
|
::ActiveRecord::Base.connection.select_value(query)
|
79
82
|
end
|
80
83
|
|