ejson-rails 0.2.2 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6d62b4bf362a99bed1a71b0a16cc83bd610157b8e3a06d8998a8c4d1a9479f9
4
- data.tar.gz: b74ef1b02227276aed05fc815d876218046bdef4533013d4ca61c0287a79e22a
3
+ metadata.gz: 3bede97f3d90eb8a1088a761e2bab8c883f07c9262f408a3dbb0578c783b34c0
4
+ data.tar.gz: 95521f7ebf60e54fb51876f4bedbbf343bac5a9bad08fcb89e3a3c5daac587a7
5
5
  SHA512:
6
- metadata.gz: d8d136c6ef01aaf7011c0f8edb1f301654e813de2de0cff764422dabb929cea9b8df2e73eea3cb5f5a991a67166004f6bd62f0c0419984071fa8bc8b3009d549
7
- data.tar.gz: 325e1a3e46fb0abfdd33b85002359768318dfac8fa6682cc9c09a17130604aa445aa98efcce57156a94cf9abda1d5bbec1315b4178b8830fe1e5e1d0f596f98a
6
+ metadata.gz: 4c402407b30ac8948a9cb8a6e3f36addaebf123e3a06672d8731cebee91a6e412524a51a5028059de56628fc46425b48548b48aab31a2cf5b81228b843bf93a9
7
+ data.tar.gz: 92f0fe6b5cc46616f83d4952e39c92fb008b707042e4e11c9f8f25418bf373f1c7345454cebe08a27aa6b4645f2acd3af67976472c84796dcaffc35146f688a5
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: /
5
+ schedule:
6
+ interval: weekly
7
+ open-pull-requests-limit: 100
data/Gemfile.lock CHANGED
@@ -1,75 +1,77 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ejson-rails (0.2.2)
4
+ ejson-rails (1.0.0)
5
5
  ejson
6
6
  railties (>= 6.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (7.1.3.2)
12
- actionview (= 7.1.3.2)
13
- activesupport (= 7.1.3.2)
11
+ actionpack (7.2.0)
12
+ actionview (= 7.2.0)
13
+ activesupport (= 7.2.0)
14
14
  nokogiri (>= 1.8.5)
15
15
  racc
16
- rack (>= 2.2.4)
16
+ rack (>= 2.2.4, < 3.2)
17
17
  rack-session (>= 1.0.1)
18
18
  rack-test (>= 0.6.3)
19
19
  rails-dom-testing (~> 2.2)
20
20
  rails-html-sanitizer (~> 1.6)
21
- actionview (7.1.3.2)
22
- activesupport (= 7.1.3.2)
21
+ useragent (~> 0.16)
22
+ actionview (7.2.0)
23
+ activesupport (= 7.2.0)
23
24
  builder (~> 3.1)
24
25
  erubi (~> 1.11)
25
26
  rails-dom-testing (~> 2.2)
26
27
  rails-html-sanitizer (~> 1.6)
27
- activesupport (7.1.3.2)
28
+ activesupport (7.2.0)
28
29
  base64
29
30
  bigdecimal
30
- concurrent-ruby (~> 1.0, >= 1.0.2)
31
+ concurrent-ruby (~> 1.0, >= 1.3.1)
31
32
  connection_pool (>= 2.2.5)
32
33
  drb
33
34
  i18n (>= 1.6, < 2)
35
+ logger (>= 1.4.2)
34
36
  minitest (>= 5.1)
35
- mutex_m
36
- tzinfo (~> 2.0)
37
+ securerandom (>= 0.3)
38
+ tzinfo (~> 2.0, >= 2.0.5)
37
39
  ast (2.4.2)
38
40
  base64 (0.2.0)
39
- bigdecimal (3.1.6)
40
- builder (3.2.4)
41
- concurrent-ruby (1.2.3)
41
+ bigdecimal (3.1.8)
42
+ builder (3.3.0)
43
+ concurrent-ruby (1.3.4)
42
44
  connection_pool (2.4.1)
43
45
  crass (1.0.6)
44
46
  diff-lcs (1.5.1)
45
47
  drb (2.2.1)
46
48
  ejson (1.4.1)
47
- erubi (1.12.0)
48
- i18n (1.14.1)
49
+ erubi (1.13.0)
50
+ i18n (1.14.5)
49
51
  concurrent-ruby (~> 1.0)
50
- io-console (0.6.0)
51
- irb (1.10.0)
52
- rdoc
53
- reline (>= 0.3.8)
54
- json (2.7.1)
52
+ io-console (0.7.2)
53
+ irb (1.14.0)
54
+ rdoc (>= 4.0.0)
55
+ reline (>= 0.4.2)
56
+ json (2.7.2)
55
57
  language_server-protocol (3.17.0.3)
58
+ logger (1.6.0)
56
59
  loofah (2.22.0)
57
60
  crass (~> 1.0.2)
58
61
  nokogiri (>= 1.12.0)
59
- mini_portile2 (2.8.5)
60
- minitest (5.22.2)
61
- mutex_m (0.2.0)
62
- nokogiri (1.15.6)
62
+ mini_portile2 (2.8.7)
63
+ minitest (5.25.0)
64
+ nokogiri (1.16.7)
63
65
  mini_portile2 (~> 2.8.2)
64
66
  racc (~> 1.4)
65
- parallel (1.24.0)
66
- parser (3.3.0.5)
67
+ parallel (1.25.1)
68
+ parser (3.3.4.0)
67
69
  ast (~> 2.4.1)
68
70
  racc
69
71
  psych (5.1.2)
70
72
  stringio
71
- racc (1.7.3)
72
- rack (3.0.9.1)
73
+ racc (1.8.1)
74
+ rack (3.1.7)
73
75
  rack-session (2.0.0)
74
76
  rack (>= 3.0.0)
75
77
  rack-test (2.1.0)
@@ -84,58 +86,62 @@ GEM
84
86
  rails-html-sanitizer (1.6.0)
85
87
  loofah (~> 2.21)
86
88
  nokogiri (~> 1.14)
87
- railties (7.1.3.2)
88
- actionpack (= 7.1.3.2)
89
- activesupport (= 7.1.3.2)
90
- irb
89
+ railties (7.2.0)
90
+ actionpack (= 7.2.0)
91
+ activesupport (= 7.2.0)
92
+ irb (~> 1.13)
91
93
  rackup (>= 1.0.0)
92
94
  rake (>= 12.2)
93
95
  thor (~> 1.0, >= 1.2.2)
94
96
  zeitwerk (~> 2.6)
95
97
  rainbow (3.1.1)
96
- rake (13.0.6)
97
- rdoc (6.6.3.1)
98
+ rake (13.2.1)
99
+ rdoc (6.7.0)
98
100
  psych (>= 4.0.0)
99
- regexp_parser (2.9.0)
100
- reline (0.4.1)
101
+ regexp_parser (2.9.2)
102
+ reline (0.5.9)
101
103
  io-console (~> 0.5)
102
- rexml (3.2.6)
103
- rspec (3.12.0)
104
- rspec-core (~> 3.12.0)
105
- rspec-expectations (~> 3.12.0)
106
- rspec-mocks (~> 3.12.0)
107
- rspec-core (3.12.2)
108
- rspec-support (~> 3.12.0)
109
- rspec-expectations (3.12.3)
104
+ rexml (3.3.4)
105
+ strscan
106
+ rspec (3.13.0)
107
+ rspec-core (~> 3.13.0)
108
+ rspec-expectations (~> 3.13.0)
109
+ rspec-mocks (~> 3.13.0)
110
+ rspec-core (3.13.0)
111
+ rspec-support (~> 3.13.0)
112
+ rspec-expectations (3.13.0)
110
113
  diff-lcs (>= 1.2.0, < 2.0)
111
- rspec-support (~> 3.12.0)
112
- rspec-mocks (3.12.6)
114
+ rspec-support (~> 3.13.0)
115
+ rspec-mocks (3.13.1)
113
116
  diff-lcs (>= 1.2.0, < 2.0)
114
- rspec-support (~> 3.12.0)
115
- rspec-support (3.12.1)
116
- rubocop (1.62.1)
117
+ rspec-support (~> 3.13.0)
118
+ rspec-support (3.13.1)
119
+ rubocop (1.65.1)
117
120
  json (~> 2.3)
118
121
  language_server-protocol (>= 3.17.0)
119
122
  parallel (~> 1.10)
120
123
  parser (>= 3.3.0.2)
121
124
  rainbow (>= 2.2.2, < 4.0)
122
- regexp_parser (>= 1.8, < 3.0)
125
+ regexp_parser (>= 2.4, < 3.0)
123
126
  rexml (>= 3.2.5, < 4.0)
124
127
  rubocop-ast (>= 1.31.1, < 2.0)
125
128
  ruby-progressbar (~> 1.7)
126
129
  unicode-display_width (>= 2.4.0, < 3.0)
127
- rubocop-ast (1.31.2)
128
- parser (>= 3.3.0.4)
129
- rubocop-shopify (2.11.1)
130
- rubocop (~> 1.42)
130
+ rubocop-ast (1.31.3)
131
+ parser (>= 3.3.1.0)
132
+ rubocop-shopify (2.15.1)
133
+ rubocop (~> 1.51)
131
134
  ruby-progressbar (1.13.0)
132
- stringio (3.1.0)
133
- thor (1.3.0)
135
+ securerandom (0.3.1)
136
+ stringio (3.1.1)
137
+ strscan (3.1.0)
138
+ thor (1.3.1)
134
139
  tzinfo (2.0.6)
135
140
  concurrent-ruby (~> 1.0)
136
141
  unicode-display_width (2.5.0)
142
+ useragent (0.16.10)
137
143
  webrick (1.8.1)
138
- zeitwerk (2.6.12)
144
+ zeitwerk (2.6.17)
139
145
 
140
146
  PLATFORMS
141
147
  ruby
@@ -148,4 +154,4 @@ DEPENDENCIES
148
154
  rubocop-shopify
149
155
 
150
156
  BUNDLED WITH
151
- 2.5.7
157
+ 2.5.10
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://github.com/Shopify/ejson-rails/workflows/CI/badge.svg?branch=main)](https://github.com/Shopify/ejson-rails/actions?query=branch%3Amain)
4
4
 
5
- Automatically injects [`ejson`](https://github.com/Shopify/ejson) decrypted secrets into your `Rails.application.secrets`.
5
+ Automatically injects [`ejson`](https://github.com/Shopify/ejson) decrypted secrets into your `Rails.application.credentials`.
6
6
 
7
7
  ## Installation
8
8
 
@@ -52,7 +52,7 @@ EJSON::Rails::Railtie.ejson_secret_source = proc { '{"secret": "secret_from_ejso
52
52
 
53
53
  ## Usage
54
54
 
55
- Decrypted secrets and credentials will be accessible via `Rails.application.secrets`. For example:
55
+ Decrypted secrets will be accessible via `Rails.application.credentials`. For example:
56
56
 
57
57
  `# project/config/secrets.json`
58
58
 
@@ -60,9 +60,9 @@ Decrypted secrets and credentials will be accessible via `Rails.application.secr
60
60
  { "some_secret": "key" }
61
61
  ```
62
62
 
63
- will be accessible via `Rails.application.secrets.some_secret` or `Rails.application.secrets[:some_secret]` upon booting. JSON files are loaded once and contents are `deep_merge`'d into your app's existing rails secrets.
63
+ will be accessible via `Rails.application.credentials.some_secret` or `Rails.application.credentials[:some_secret]` upon booting. JSON files are loaded once and contents are `deep_merge`'d into your app's existing Rails credentials.
64
64
 
65
- Secrets will also be accessible via `Rails.application.credentials`, e.g. `Rails.application.credentials.some_secret` or `Rails.application.credentials[:some_secret]`. To avoid subtle compatibility issues, if a credential already exists, an error will occur.
65
+ To avoid subtle compatibility issues, if a credential already exists, an error will occur.
66
66
 
67
67
  If you set the `EJSON_RAILS_DELETE_SECRETS` environment variable to `true` the gem will automatically delete the secrets from the filesystem after loading them into Rails. It will delete both paths (`project/config/secrets.json` and `project/config/secrets.{current_rails_environment}.json`) if the files exist and are writable.
68
68
 
@@ -70,110 +70,7 @@ NOTE: This gem does not decrypt ejson for you. You will need to configure this a
70
70
 
71
71
  ## Migrating to credentials
72
72
 
73
- Rails 7.1 has deprecated application secrets in favor of credentials. ejson-rails can migrate secrets to application credentials.
74
-
75
- Even before running Rails 7.1, you can migrate your secrets in several steps:
76
-
77
- 1. Convert secrets from YAML to JSON
78
- 2. Move any ERB embedded within the YAML to the corresponding environment file
79
- 3. Use `Rails.application.credentials` in place of Rails secrets
80
-
81
- ### 1. Convert secrets from config/secrets.yml to config/secrets.json
82
-
83
- Typically, secrets share the same structure across different environments. While test secrets are often placeholders, development secrets may sometimes use environment variables to communicate with external services.
84
- In that case, the easiest way to migrate is to use the test secrets in all local environments, and override for development as needed:
85
-
86
- ```sh-session
87
- # Recommended
88
- bin/rails runner -e test 'Rails.root.join("config/secrets.json").write(JSON.pretty_generate(Rails.application.secrets.to_h.without(:secret_key_base)))'
89
- ```
90
-
91
- > [!NOTE]
92
- > Alternatively, if its necessary to configure distinct values between the development/test environment, you can use separate JSON files for the development/test environments:
93
- >
94
- > ```sh-session
95
- > bin/rails runner 'Rails.root.join("config/secrets.#{Rails.env}.json").write(JSON.pretty_generate(Rails.application.secrets.to_h.without(:secret_key_base)))'
96
- > bin/rails runner -e test 'Rails.root.join("config/secrets.#{Rails.env}.json").write(JSON.pretty_generate(Rails.application.secrets.to_h.without(:secret_key_base)))'
97
- > ```
98
-
99
- ### 2. Move any ERB into the corresponding environment files
100
-
101
- YAML supports ERB while JSON secrets do not. If your secrets contain ERB, you will need to move that logic to the corresponding environment file:
102
-
103
- **Before**:
104
-
105
- `config/secrets.yml`
106
-
107
- ```yaml
108
- development:
109
- some_external_service:
110
- api_token: <%= ENV.fetch(SOME_EXTERNAL_SERVICE_API_TOKEN, "12345") %>
111
- ```
112
-
113
- **After**:
114
-
115
- `config/secrets.json` as generated by the _recommended_ command above.
116
-
117
- ```json
118
- {
119
- "some_external_service": {
120
- "api_token": "12345"
121
- },
122
- "something_else_entirely": "abc"
123
- }
124
- ```
125
-
126
- `config/environments/development.rb`
127
-
128
- ```ruby
129
- Rails.application.configure do
130
- # elided
131
-
132
- credentials.some_external_service.api_token = ENV.fetch("SOME_EXTERNAL_SERVICE_API_TOKEN", "12345")
133
- credentials.something_else_entirely = ENV.fetch("SOMETHING_ELSE_ENTIRELY", "abc")
134
- end
135
- ```
136
-
137
- #### Rails 7.0 Note
138
-
139
- > [!NOTE]
140
- > In Rails 7.0, credentials are accessed as a Hash with [] and []=.. This is important because the dynamic accessor methods will set values in a different object, and credentials will behave inconsistently after that:
141
-
142
- ```ruby
143
- Rails.application.credentials.some_external_service.api_token = "foo"
144
- Rails.application.credentials[:some_external_service][:api_token] # => "12345"
145
- ```
146
-
147
- Also note the code sets top-level values through `credentials.config`, because `credentials#[]=(key, value)` sets values in a different object.
148
-
149
- ```ruby
150
- Rails.application.credentials[:something_else_entirely] = "foo"
151
- Rails.application.credentials[:something_else_entirely] # => "abc"
152
- ```
153
-
154
- Make sure there's no code using the dynamic accessors before setting the configuration in the Hash, or the values won't be accessible from the dynamic accessor:
155
-
156
- ```ruby
157
- Rails.application.credentials.something_else_entirely # just accessing is enough to cause the issue
158
- Rails.application.credentials[:some_external_service][:api_token] = "foo"
159
- Rails.application.credentials.some_external_service.api_token # => "12345"
160
- ```
161
-
162
- ### 3. Use `Rails.application.credentials`
163
-
164
- You are now ready to replace Rails secrets with Rails credentials:
165
-
166
- ```sh-session
167
- git ls-files | xargs ruby -pi -e 'gsub("Rails.application.secrets", "Rails.application.credentials")' --
168
- ```
169
-
170
- To avoid the deprecation warning from the use of secrets in `ejson-rails` once you're running Rails 7.1, require another file from your Gemfile:
171
-
172
- ```ruby
173
- gem 'ejson-rails', require: 'ejson/rails/skip_secrets'
174
- ```
175
-
176
- With this require, ejson-rails will no longer merge secrets from JSON into `Rails.application.secrets`. This will be the default in the next major version.
73
+ Rails 7.1 has deprecated application secrets in favor of credentials. `ejson-rails` no longer writes to Rails secrets to avoid crashing given Rails 7.2 removal of the feature. See the README for the last version that supports secrets to read more about migrating: [`ejson-rails` v0.2.2 – Migrating to credentials](https://github.com/Shopify/ejson-rails/tree/v0.2.2#migrating-to-credentials).
177
74
 
178
75
  ## Development
179
76
 
@@ -6,8 +6,7 @@ module EJSON
6
6
  private_constant :Rails
7
7
 
8
8
  class Railtie < Rails::Railtie
9
- singleton_class.attr_accessor(:ejson_secret_source, :set_secrets)
10
- @set_secrets = true
9
+ singleton_class.attr_accessor(:ejson_secret_source)
11
10
 
12
11
  config.before_configuration do
13
12
  secrets = load_secrets_from_config || load_secrets_from_disk
@@ -15,7 +14,6 @@ module EJSON
15
14
 
16
15
  secrets = JSON.parse(secrets, symbolize_names: true)
17
16
 
18
- Rails.application.secrets.deep_merge!(secrets) if set_secrets
19
17
  # Merging into `credentials.config` because in Rails 7.0, reading a credential with
20
18
  # Rails.application.credentials[:some_credential] won't work otherwise.
21
19
  Rails.application.credentials.config.deep_merge!(secrets) do |key|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ warn 'Requiring "ejson/rails/skip_secrets" is deprecated. ' \
4
+ 'Use `require "ejson/rails" or remove the `:require` option from your Gemfile.'
3
5
  require "ejson/rails"
4
-
5
- EJSON::Rails::Railtie.set_secrets = false
@@ -2,6 +2,6 @@
2
2
 
3
3
  module EJSON
4
4
  module Rails
5
- VERSION = "0.2.2"
5
+ VERSION = "1.0.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ejson-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gannon McGibbon
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-09 00:00:00.000000000 Z
11
+ date: 2024-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ejson
@@ -74,6 +74,7 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
+ - ".github/dependabot.yml"
77
78
  - ".github/workflows/ci.yml"
78
79
  - ".github/workflows/cla.yml"
79
80
  - ".gitignore"
@@ -101,7 +102,7 @@ licenses:
101
102
  - MIT
102
103
  metadata:
103
104
  allowed_push_host: https://rubygems.org
104
- post_install_message:
105
+ post_install_message:
105
106
  rdoc_options: []
106
107
  require_paths:
107
108
  - lib
@@ -116,8 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
117
  - !ruby/object:Gem::Version
117
118
  version: '0'
118
119
  requirements: []
119
- rubygems_version: 3.5.10
120
- signing_key:
120
+ rubygems_version: 3.5.17
121
+ signing_key:
121
122
  specification_version: 4
122
123
  summary: Asymmetric keywise encryption for JSON on Rails
123
124
  test_files: []