rails_surrogate_key_logging 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea7560b27adda872ef0742f8d5be560541849824d8cf3ec5ceaba42b50e2a4f7
4
- data.tar.gz: a5ed6d8ced6c1fca2067dea1c4c975df569534542e2c0f8caf53ddac9298bb7b
3
+ metadata.gz: 0c90ffc261a0cc4de8d88266fd00e0ce40c4c5a1802cf60b2fdaa72c6d345d61
4
+ data.tar.gz: 13dfb52ddf21fd49d28930043a4c8a3160c466fb2a03dfc8e9e369ad9b0007ab
5
5
  SHA512:
6
- metadata.gz: 5ea28f7ec2eae90380bf4d786fa640bcf3d6489ca594ee7b76fe8f36b87d284fb3e6d8b1d3c7349f32fb947ee123c3614e98be1859f9e77313b7f3acf6e3a20c
7
- data.tar.gz: 2d23b23e491b82ee53daa5987666797622912c9d915d8f63213668811fcfc7bf2b7ce248b316b1c5ede1d2702f4e637f9bbb3fb19e548340476a8d3c4cd240f9
6
+ metadata.gz: cc2df820cec2c3c042552fd8e9e7f16c87b5c8592228a9f8c03e9c91e40417d5c0b7cf8cb2e15d729e56837e7ec6cccbb63a75e10c8cfd633ff55c6e029a7668
7
+ data.tar.gz: 80ce2c893ef9394acec270591f2c63d4f5603d701fd12eb8562a9b23a9d07555f8af0481a0e1df92692900e080bf826025cd20f77295514e8ac5fe0186a659cd
@@ -17,11 +17,6 @@ module SurrogateKeyLogging
17
17
  g.templates.unshift File.expand_path('lib/templates', root)
18
18
  end
19
19
 
20
- rake_tasks do
21
- # load 'tasks/surrogate_key_logging.rake'
22
- # load 'tasks/key_store/active_record.rake'
23
- end
24
-
25
20
  initializer 'surrogate_key_logging.config' do |app|
26
21
  SurrogateKeyLogging.configure do |config|
27
22
  config.enabled = Rails.env.production? unless config.key?(:enabled)
@@ -35,7 +30,9 @@ module SurrogateKeyLogging
35
30
  end
36
31
 
37
32
  initializer 'surrogate_key_logging.middleware' do |app|
38
- app.middleware.insert_before(0, Middleware)
33
+ if SurrogateKeyLogging.config.enabled
34
+ app.middleware.insert_before(0, Middleware)
35
+ end
39
36
  end
40
37
 
41
38
  initializer 'surrogate_key_logging.filter_parameters' do
@@ -53,5 +50,15 @@ module SurrogateKeyLogging
53
50
  end
54
51
  end
55
52
 
53
+ initializer 'surrogate_key_logging.sidekiq' do
54
+ if SurrogateKeyLogging.config.enabled && defined?(::Sidekiq)
55
+ Sidekiq.configure_server do |config|
56
+ config.server_middleware do |chain|
57
+ chain.prepend SurrogateKeyLogging::SidekiqMiddleware
58
+ end
59
+ end
60
+ end
61
+ end
62
+
56
63
  end
57
64
  end
@@ -39,3 +39,14 @@ if defined?(::Sidekiq)
39
39
 
40
40
  end
41
41
  end
42
+
43
+ module SurrogateKeyLogging
44
+ class SidekiqMiddleware
45
+
46
+ def call(env)
47
+ yield
48
+ SurrogateKeyLogging.reset
49
+ end
50
+
51
+ end
52
+ end
@@ -4,7 +4,7 @@ module SurrogateKeyLogging
4
4
 
5
5
  module Version
6
6
  MAJOR = 1
7
- MINOR = 3
7
+ MINOR = 4
8
8
  PATCH = 0
9
9
 
10
10
  end
@@ -41,7 +41,7 @@ module SurrogateKeyLogging
41
41
  def reset
42
42
  reset! if config.cache
43
43
  end
44
-
44
+
45
45
  def reset!
46
46
  @key_manager = @parameter_filter = nil
47
47
  end
@@ -55,7 +55,7 @@ module SurrogateKeyLogging
55
55
  end
56
56
 
57
57
  def filter_for_attributes(attrs)
58
- ::ActiveSupport::ParameterFilter.new(attrs, mask: key_manager)
58
+ config.enabled ? ::ActiveSupport::ParameterFilter.new(attrs, mask: key_manager) : attrs
59
59
  end
60
60
 
61
61
  def key_store
@@ -63,11 +63,11 @@ module SurrogateKeyLogging
63
63
  end
64
64
 
65
65
  def filter_parameters(params)
66
- parameter_filter.filter params
66
+ config.enabled ? parameter_filter.filter(params) : params
67
67
  end
68
68
 
69
69
  def surrogate_for(value)
70
- key_manager.get(value)
70
+ config.enabled ? key_manager.get(value) : value
71
71
  end
72
72
 
73
73
  def add_param_to_filter(attr, *parents)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_surrogate_key_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Yelverton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-01 00:00:00.000000000 Z
11
+ date: 2023-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack