eyaml 0.4.0 → 0.4.2
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/workflows/test.yml +1 -1
- data/Gemfile.lock +16 -12
- data/README.md +59 -4
- data/eyaml.gemspec +1 -0
- data/lib/eyaml/railtie.rb +6 -0
- data/lib/eyaml/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3db8844c2bbddc8461708c26243e51830e6caabb0863b51a255dcef05f762842
|
4
|
+
data.tar.gz: bc1103be88e0418663ce58bfc7f4b497466a9fe98a08b5ddddafae76d18667ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b6f9ebcae7c5a2b7920abb7ec5e75e06c1ac2e51eff9b8ea7f61a00305c80e06b60bcc3219a5b94700a6d4af6ba6915f92c646573d00a4fb1a43732aa331ec1
|
7
|
+
data.tar.gz: 4d6359cad8b3514dd4fdc8ecfe9ccfed07bd9e18a5d5bd6033633696111754e522001a18cc8c9746da0f065ee14bc8a2f6a7b009bd2bd7926293e2b658a9ccdc
|
data/.github/workflows/test.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -41,7 +41,10 @@ GEM
|
|
41
41
|
concurrent-ruby (1.2.3)
|
42
42
|
connection_pool (2.4.1)
|
43
43
|
crass (1.0.6)
|
44
|
-
|
44
|
+
debug (1.9.2)
|
45
|
+
irb (~> 1.10)
|
46
|
+
reline (>= 0.3.8)
|
47
|
+
diff-lcs (1.5.1)
|
45
48
|
drb (2.2.0)
|
46
49
|
ruby2_keywords
|
47
50
|
erubi (1.12.0)
|
@@ -99,19 +102,19 @@ GEM
|
|
99
102
|
psych (>= 4.0.0)
|
100
103
|
reline (0.4.2)
|
101
104
|
io-console (~> 0.5)
|
102
|
-
rspec (3.
|
103
|
-
rspec-core (~> 3.
|
104
|
-
rspec-expectations (~> 3.
|
105
|
-
rspec-mocks (~> 3.
|
106
|
-
rspec-core (3.
|
107
|
-
rspec-support (~> 3.
|
108
|
-
rspec-expectations (3.
|
105
|
+
rspec (3.13.0)
|
106
|
+
rspec-core (~> 3.13.0)
|
107
|
+
rspec-expectations (~> 3.13.0)
|
108
|
+
rspec-mocks (~> 3.13.0)
|
109
|
+
rspec-core (3.13.0)
|
110
|
+
rspec-support (~> 3.13.0)
|
111
|
+
rspec-expectations (3.13.0)
|
109
112
|
diff-lcs (>= 1.2.0, < 2.0)
|
110
|
-
rspec-support (~> 3.
|
111
|
-
rspec-mocks (3.
|
113
|
+
rspec-support (~> 3.13.0)
|
114
|
+
rspec-mocks (3.13.1)
|
112
115
|
diff-lcs (>= 1.2.0, < 2.0)
|
113
|
-
rspec-support (~> 3.
|
114
|
-
rspec-support (3.
|
116
|
+
rspec-support (~> 3.13.0)
|
117
|
+
rspec-support (3.13.1)
|
115
118
|
ruby2_keywords (0.0.5)
|
116
119
|
stringio (3.1.0)
|
117
120
|
thor (1.3.0)
|
@@ -126,6 +129,7 @@ PLATFORMS
|
|
126
129
|
x86_64-linux
|
127
130
|
|
128
131
|
DEPENDENCIES
|
132
|
+
debug
|
129
133
|
eyaml!
|
130
134
|
fakefs
|
131
135
|
ffi (~> 1.15.5)
|
data/README.md
CHANGED
@@ -55,12 +55,13 @@ Options:
|
|
55
55
|
```shell
|
56
56
|
-> % eyaml encrypt config/secrets.production.eyaml
|
57
57
|
Wrote 517 bytes to config/secrets.production.eyaml.
|
58
|
-
```
|
59
58
|
|
59
|
+
Note: entries starting with an `_` won't be encrypted. This has to be the case for the `_public_key`, but can be handy if you want to add keys in there that you dont't want to encrypt. Like a public key for ex.
|
60
|
+
```
|
60
61
|
|
61
62
|
#### `eyaml decrypt`
|
62
63
|
|
63
|
-
Decrypts the provided EYAML file.
|
64
|
+
Decrypts the whole provided EYAML file.
|
64
65
|
|
65
66
|
```shell
|
66
67
|
-> % eyaml decrypt config/secrets.production.eyaml
|
@@ -78,7 +79,7 @@ _public_key: a3dbdef9efd1e52a34588de56a6cf9b03bbc2aaf0edda145cfbd9a6370a0a849
|
|
78
79
|
my_secret: 85d1fca99d98c4e7b83b868f75f809e1e33346317b0c354b593cdcdc8793ad4e
|
79
80
|
```
|
80
81
|
|
81
|
-
The private key must be saved in the default key directory (`/opt/ejson/keys`) with the filename being the public key and the contents, the private key, a key directory you'll provide later, or just pass the `--write` flag for `eyaml` to handle it for you.
|
82
|
+
The private key must be saved in the default key directory (`/opt/ejson/keys`) or the `EJSON_PRIVATE_KEY` must point to the right directory, with the filename being the public key and the contents, the private key, a key directory you'll provide later, or just pass the `--write` flag for `eyaml` to handle it for you.
|
82
83
|
|
83
84
|
```shell
|
84
85
|
-> % eyaml keygen
|
@@ -96,7 +97,12 @@ b01592942ba10f152bcf7c6b6734f6392554c578ff24cebcc62f9e3da6fcf302
|
|
96
97
|
|
97
98
|
### Rails
|
98
99
|
|
99
|
-
`eyaml` comes with baked in Rails support.
|
100
|
+
`eyaml` comes with baked in Rails support.
|
101
|
+
It will search for a rails secrets or credentials file in `config/`, decrypt, and load the first valid one it finds.
|
102
|
+
|
103
|
+
For this a public-private keyfile needs to be present, which you can generate with `eyaml keygen`. For a development/test environment you can keep this in your
|
104
|
+
version control, but on production you want to take the proper precautions since this can contain your rails master key as well.
|
105
|
+
|
100
106
|
Credential files have priority over secrets before rails 7.2:
|
101
107
|
`credentials.{eyaml|eyml|ejson}` (e.g. `config/credentials.eyaml`) then `credentials.$env.{eyaml|eyml|ejson}` (e.g. `credentials.production.eyml`).
|
102
108
|
Then if no credentials are found it will look for a secrets file:
|
@@ -106,6 +112,55 @@ Note: From rails 7.2 onwards secrets are deprecated and eyaml will only look for
|
|
106
112
|
|
107
113
|
Instead of needing a private key locally, you can provide it to EYAML by setting `EJSON_PRIVATE_KEY` and it'll be automatically used for decrypting the secrets file.
|
108
114
|
|
115
|
+
If you put your rails master key encrypted in the eyaml file, make sure you don't have another `master.key` file somewhere, since that can interfere.
|
116
|
+
|
117
|
+
### Example setup
|
118
|
+
|
119
|
+
To add encryption + credentials to a rails project do the following things:
|
120
|
+
|
121
|
+
- Generate a private-public keypair with (or add the --write flag and a keypair file will be written to `/opt/ejson/keys/`):
|
122
|
+
```shell
|
123
|
+
eyaml keygen
|
124
|
+
|
125
|
+
Public Key: a3dbdef9efd1e52a34588de56a6cf9b03bbc2aaf0edda145cfbd9a6370a0a849
|
126
|
+
Private Key: b01592942ba10f152bcf7c6b6734f6392554c578ff24cebcc62f9e3da6fcf302
|
127
|
+
```
|
128
|
+
|
129
|
+
For this example I show you a dev setup, but for test, production etc. it works the same.
|
130
|
+
|
131
|
+
- Create a file with the name of the public key that contains the private key.
|
132
|
+
If you don't want to add the file to the `/opt/ejson/keys/` (for for example a dev/test environment) so you can check it in with your version management you can set the `EJSON_KEYDIR` to the keypair file
|
133
|
+
in rails `application.rb` like so:
|
134
|
+
```ruby
|
135
|
+
ENV["EJSON_KEYDIR"] = File.expand_path("../dev/ejson-keys", __dir__) unless Rails.env.production?
|
136
|
+
```
|
137
|
+
and rails will look there for the file decryption when the environment loads.
|
138
|
+
You can test this by calling
|
139
|
+
```ruby
|
140
|
+
Rails.application.credentials.secret_key_base
|
141
|
+
```
|
142
|
+
in a rails console and it should give you back the unencrypted key.
|
143
|
+
|
144
|
+
Note that you should not have a `config/master.key` file present (created by rails when using it's credentials management like for ex when calling `rails credentials:edit`) when using eyaml.
|
145
|
+
Eyaml is a replacement for rails's credentials management and currently conflicts with it. Eyaml will raise when a master.key is present.
|
146
|
+
|
147
|
+
- Create a `config/credentials.development.eyaml` file
|
148
|
+
- In the credentials file add:
|
149
|
+
```yaml
|
150
|
+
_public_key: a3dbdef9efd1e52a34588de56a6cf9b03bbc2aaf0edda145cfbd9a6370a0a849
|
151
|
+
```
|
152
|
+
on top
|
153
|
+
- You can then add your rails `secret_key_base` like so:
|
154
|
+
```yaml
|
155
|
+
secret_key_base: <secret>
|
156
|
+
```
|
157
|
+
And any other key you need in there.
|
158
|
+
- Then every time you edit your eyaml file(s) run (for ex for development):
|
159
|
+
```shell
|
160
|
+
eyaml encrypt config/credentials.development.eyaml
|
161
|
+
```
|
162
|
+
And you can see that the key put in there is encrypted afterwards (except the ones starting with an `_`).
|
163
|
+
|
109
164
|
### Apple M1 Support
|
110
165
|
|
111
166
|
If you're using the new Apple M1, you need to ensure that you're using a `ffi` that is working. We've temporarily been including a fork with a fix in any `Gemfile` where we've included `eyaml`:
|
data/eyaml.gemspec
CHANGED
data/lib/eyaml/railtie.rb
CHANGED
@@ -8,7 +8,13 @@ module EYAML
|
|
8
8
|
class Railtie < Rails::Railtie
|
9
9
|
PRIVATE_KEY_ENV_VAR = "EJSON_PRIVATE_KEY"
|
10
10
|
|
11
|
+
class ConflictError < StandardError
|
12
|
+
end
|
13
|
+
|
11
14
|
config.before_configuration do
|
15
|
+
if File.exist?(Rails.root.join("config", "master.key"))
|
16
|
+
raise ConflictError, "A config/master.key has been found. The rails credentials lookup conflicts with eyaml. Please remove rails credentials management by removing the master.key file to keep using eyaml."
|
17
|
+
end
|
12
18
|
secret_files_present = Dir.glob(auth_files(:secrets)).any?
|
13
19
|
credential_files_present = Dir.glob(auth_files(:credentials)).any?
|
14
20
|
|
data/lib/eyaml/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eyaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Stolarsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: debug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: Secret management by encrypting values in a YAML file with a public/private
|
70
84
|
keypair
|
71
85
|
email:
|