creds 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -3
- data/Gemfile +0 -2
- data/Gemfile.lock +6 -6
- data/README.md +16 -6
- data/creds.gemspec +1 -1
- data/lib/creds.rb +4 -1
- data/lib/creds/version.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9231cfcb9ee46f7178ba33a009dec23e20fa329bb124a7ce21b999f441fa1ceb
|
4
|
+
data.tar.gz: efd6de47e0242203f6cb8fbc28621499b64ff2e2cdfcc739d19359b31cf8f74a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b24d7b241e05bd17a19c19805baebd59c13a8f6bddb6b377833f18757940b7d5ae489ef2ccdc1845393878eeefcc542b89bcdfa2395e7a0486fd1409175f601
|
7
|
+
data.tar.gz: e736ea8764447a1813f43b553a24368826a0da9169cbb2741e1598a5d47c5d9be6b751b940117ed854852571b7b7f1cb448a538789c162abf823c0eebad5ab58
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
creds (1.0.
|
4
|
+
creds (1.0.1)
|
5
5
|
activesupport (>= 5.2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (5.2.
|
10
|
+
activesupport (5.2.3)
|
11
11
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
12
|
i18n (>= 0.7, < 2)
|
13
13
|
minitest (~> 5.1)
|
14
14
|
tzinfo (~> 1.1)
|
15
|
-
concurrent-ruby (1.
|
16
|
-
i18n (1.
|
15
|
+
concurrent-ruby (1.1.5)
|
16
|
+
i18n (1.6.0)
|
17
17
|
concurrent-ruby (~> 1.0)
|
18
18
|
minitest (5.11.3)
|
19
|
-
rake (12.3.
|
19
|
+
rake (12.3.2)
|
20
20
|
thread_safe (0.3.6)
|
21
21
|
tzinfo (1.2.5)
|
22
22
|
thread_safe (~> 0.1)
|
@@ -31,4 +31,4 @@ DEPENDENCIES
|
|
31
31
|
rake (>= 10.0)
|
32
32
|
|
33
33
|
BUNDLED WITH
|
34
|
-
|
34
|
+
2.0.1
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ Available as a gem [`creds`](https://rubygems.org/gems/creds)
|
|
10
10
|
|
11
11
|
Using Rails command, generate new encrypted file by
|
12
12
|
```
|
13
|
-
bin/rails encrypted:edit config/credentials
|
13
|
+
bin/rails encrypted:edit config/credentials/production.yml.enc --key config/credentials/production.key
|
14
14
|
```
|
15
15
|
|
16
16
|
add some content in opened editor (note there is no environment root key, ie no `production`):
|
@@ -18,15 +18,20 @@ add some content in opened editor (note there is no environment root key, ie no
|
|
18
18
|
aws_access_key_id: my-access-key-id
|
19
19
|
```
|
20
20
|
|
21
|
-
If `config/
|
21
|
+
If `config/credentials/production.key` doesn't exist yet, run `bin/rails generate master_key` and adjust naming to match desired one.
|
22
22
|
Content of file can be displayed by
|
23
23
|
```
|
24
|
-
bin/rails encrypted:show config/credentials
|
24
|
+
bin/rails encrypted:show config/credentials/production.yml.enc --key config/credentials/production.key
|
25
25
|
```
|
26
26
|
|
27
27
|
Add to `config/environments/production.rb` (or any other env)
|
28
28
|
```ruby
|
29
|
-
config.creds = Creds.new("config/credentials
|
29
|
+
config.creds = Creds.new("config/credentials/production.yml.enc")
|
30
|
+
```
|
31
|
+
|
32
|
+
If wants to use key from custom path - by default it checks `RAILS_MASTER_KEY` env key and `config/master.key` file:
|
33
|
+
```ruby
|
34
|
+
config.creds = Creds.new("config/credentials/production.yml.enc", key_path: "config/credentials/production.key")
|
30
35
|
```
|
31
36
|
|
32
37
|
In the code:
|
@@ -34,7 +39,7 @@ In the code:
|
|
34
39
|
Rails.configuration.creds.aws_access_key_id
|
35
40
|
```
|
36
41
|
|
37
|
-
To ease working in development/test environments with the same API, add `config/credentials
|
42
|
+
To ease working in development/test environments with the same API, add `config/credentials/plain.yml` with key/value pairs
|
38
43
|
nested under environment name, like:
|
39
44
|
```yml
|
40
45
|
development:
|
@@ -43,9 +48,14 @@ development:
|
|
43
48
|
|
44
49
|
Then add to `config/environments/development.rb`
|
45
50
|
```ruby
|
46
|
-
config.creds = Creds.new("config/credentials
|
51
|
+
config.creds = Creds.new("config/credentials/plain.yml", env: "development")
|
47
52
|
```
|
48
53
|
|
54
|
+
### Rails 6.0
|
55
|
+
|
56
|
+
In Rails 6.0 it is possible to edit files by `rails credentials:edit --environment production` which will look for
|
57
|
+
`config/credentials/production.yml.enc` encrypted by `ENV["RAILS_MASTER_KEY"]` or `config/credentials/production.key`
|
58
|
+
|
49
59
|
### Additions
|
50
60
|
|
51
61
|
* To raise error in case of missing key you can add bang to the name, like `Rails.configuration.creds.database_url!`
|
data/creds.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Wojciech Wnętrzak"]
|
10
10
|
spec.email = ["w.wnetrzak@gmail.com", "eng@freeletics.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{Encrypted
|
12
|
+
spec.summary = %q{Encrypted credentials for multiple environments}
|
13
13
|
spec.description = %q{Unified interface for encrypted credentials and plain text file based}
|
14
14
|
spec.homepage = "https://github.com/freeletics/creds"
|
15
15
|
spec.license = "MIT"
|
data/lib/creds.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require "creds/version"
|
2
2
|
require "creds/plain_configuration"
|
3
3
|
|
4
|
-
require "active_support/core_ext/module/attribute_accessors" # https://github.com/rails/rails/pull/32383
|
5
4
|
require "active_support/core_ext/module/delegation"
|
6
5
|
require "active_support/encrypted_configuration"
|
7
6
|
|
@@ -18,6 +17,10 @@ class Creds
|
|
18
17
|
@env = env
|
19
18
|
end
|
20
19
|
|
20
|
+
def [](key)
|
21
|
+
configuration[key.to_sym]
|
22
|
+
end
|
23
|
+
|
21
24
|
def configuration
|
22
25
|
@configuration ||= if @file_path.end_with?(".enc")
|
23
26
|
ActiveSupport::EncryptedConfiguration.new(
|
data/lib/creds/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: creds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wojciech Wnętrzak
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -107,9 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
|
-
|
111
|
-
rubygems_version: 2.7.6
|
110
|
+
rubygems_version: 3.0.3
|
112
111
|
signing_key:
|
113
112
|
specification_version: 4
|
114
|
-
summary: Encrypted
|
113
|
+
summary: Encrypted credentials for multiple environments
|
115
114
|
test_files: []
|