rails-env-credentials 0.1.3 → 0.1.4
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/.gitignore +1 -0
- data/.travis.yml +17 -9
- data/README.md +55 -19
- data/bin/console +1 -1
- data/gemfiles/rails_52.gemfile +5 -0
- data/lib/rails_env_credentials.rb +0 -1
- data/lib/rails_env_credentials/railtie.rb +6 -0
- data/lib/rails_env_credentials/version.rb +1 -1
- data/rails-env-credentials.gemspec +1 -1
- metadata +6 -7
- data/lib/rails_env_credentials/credentials_overwrite.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f9a2c3494b0a68a461f7d60931e994b303dbff851004365adf2d4d1ea70ceca
|
4
|
+
data.tar.gz: 8329cb9beef080f6811a989136c26034a63bc5e702c806507cd3da349700c339
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e89fc46f511cc717e0a7f1ddf6f20a6d4c0f134874e33e8c96338100289e61fbfab5c899c58d37e7246514e2af8877ec9d41e25128ed44dfd7f49e167782a0e
|
7
|
+
data.tar.gz: 7f3f223e5a1ee75825b1f0208d438021279111a00554dc6a858dbd820c8f8e10ae6d750f19c35b0a1834f7ef7a126b023c2fd2a1d8dced9e254fae71fe301fe3
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,19 +1,27 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
|
+
|
3
4
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.
|
5
|
+
- 2.4
|
6
|
+
- 2.5
|
7
|
+
- 2.6
|
6
8
|
- ruby-head
|
9
|
+
|
7
10
|
gemfile:
|
8
|
-
-
|
11
|
+
- gemfiles/rails_52.gemfile
|
9
12
|
- gemfiles/rails_edge.gemfile
|
13
|
+
|
14
|
+
before_install:
|
15
|
+
- gem update --system
|
16
|
+
- gem update bundler
|
17
|
+
|
18
|
+
cache: bundler
|
19
|
+
|
10
20
|
matrix:
|
21
|
+
exclude:
|
22
|
+
- rvm: 2.4
|
23
|
+
gemfile: gemfiles/rails_edge.gemfile
|
24
|
+
|
11
25
|
allow_failures:
|
12
26
|
- rvm: ruby-head
|
13
27
|
- gemfile: gemfiles/rails_edge.gemfile
|
14
|
-
before_install: gem install bundler -v 1.16.1
|
15
|
-
cache: bundler
|
16
|
-
notifications:
|
17
|
-
email:
|
18
|
-
on_success: never
|
19
|
-
on_failure: change
|
data/README.md
CHANGED
@@ -5,22 +5,6 @@
|
|
5
5
|
|
6
6
|
It enhances the Credentials feature introduced by Rails v5.2.0.
|
7
7
|
|
8
|
-
## Why make it?
|
9
|
-
|
10
|
-
Credentials is a good feature, but we cannot use it on development and test environment.
|
11
|
-
|
12
|
-
DHH wrote as follow in the pull request for initial implementation:
|
13
|
-
|
14
|
-
> It's only in production (and derivative environments, like exposed betas) where the secret actually needs to be secret.
|
15
|
-
>
|
16
|
-
> refs: https://github.com/rails/rails/pull/30067
|
17
|
-
|
18
|
-
However, I have to manage secrets in the staging environment.
|
19
|
-
|
20
|
-
I do not have the confidence to explain explicit use cases to Rails team, so I implemented as a gem.
|
21
|
-
|
22
|
-
If many people use it, I would like to send a pull request to Rails.:octocat::heart:
|
23
|
-
|
24
8
|
## Installation
|
25
9
|
|
26
10
|
Add this line to your Rails application's Gemfile:
|
@@ -39,13 +23,47 @@ $ bundle
|
|
39
23
|
|
40
24
|
## Usage
|
41
25
|
|
42
|
-
RailsEnvCredentials
|
26
|
+
RailsEnvCredentials manages credentials and key pairs with the following:
|
27
|
+
|
28
|
+
```
|
29
|
+
config/credentials-development.yml.enc
|
30
|
+
config/credentials-test.yml.enc
|
31
|
+
config/credentials.yml.enc
|
32
|
+
master-development.key
|
33
|
+
master-test.key
|
34
|
+
master.key
|
35
|
+
```
|
36
|
+
|
37
|
+
You can use appropriate credentials depending on `Rails.env`.
|
38
|
+
|
39
|
+
```console
|
40
|
+
$ rails env_credentials:show -e development
|
41
|
+
# config/credentials-development.yml.enc
|
42
|
+
aws:
|
43
|
+
bucket: foo-dev
|
44
|
+
|
45
|
+
$ rails env_credentials:show -e production
|
46
|
+
# config/credentials.yml.enc
|
47
|
+
aws:
|
48
|
+
bucket: foo-prod
|
49
|
+
|
50
|
+
$ rails runner -e development 'pp Rails.application.credentials.aws.bucket'
|
51
|
+
"foo-dev"
|
52
|
+
$ rails runner -e production 'pp Rails.application.credentials.aws.bucket'
|
53
|
+
"foo-prod"
|
54
|
+
```
|
55
|
+
|
56
|
+
## Generating secrets and a master key
|
57
|
+
|
58
|
+
It automatically generate encrypted file and the master key when you starts editing credentials at first:
|
43
59
|
|
44
60
|
```
|
45
61
|
$ rails env_credentials:edit -e development
|
46
62
|
```
|
47
63
|
|
48
|
-
|
64
|
+
## Show secrets
|
65
|
+
|
66
|
+
You want to see decrypted contents, use `env_credentials:show`:
|
49
67
|
|
50
68
|
```
|
51
69
|
$ rails env_credentials:show -e development
|
@@ -55,7 +73,11 @@ $ rails env_credentials:show -e development
|
|
55
73
|
|
56
74
|
### Other environments support
|
57
75
|
|
58
|
-
For example, if the `config/environments/staging.rb` exists,
|
76
|
+
For example, if the `config/environments/staging.rb` exists, you will generate `config/credentials-staging.yml.enc`.
|
77
|
+
|
78
|
+
```
|
79
|
+
$ rails env_credentials:edit -e staging
|
80
|
+
```
|
59
81
|
|
60
82
|
### Display a diff
|
61
83
|
|
@@ -75,6 +97,20 @@ $ git config diff.env_credentials.textconv 'rails env_credentials:show --file'
|
|
75
97
|
|
76
98
|
This tells Git that encrypted files should decrypt by the `env_credentials:show` task when you try to display a diff.
|
77
99
|
|
100
|
+
## Why make this gem?
|
101
|
+
|
102
|
+
Credentials is a good feature, but we cannot use it on development and test environment.
|
103
|
+
|
104
|
+
DHH wrote as follow in the pull request for initial implementation:
|
105
|
+
|
106
|
+
> It's only in production (and derivative environments, like exposed betas) where the secret actually needs to be secret.
|
107
|
+
>
|
108
|
+
> refs: https://github.com/rails/rails/pull/30067
|
109
|
+
|
110
|
+
However, I have to manage secrets and a master key different from production for testing in the staging environment.
|
111
|
+
|
112
|
+
I do not have the confidence to explain explicit use cases to Rails team, so I implemented as a gem.
|
113
|
+
|
78
114
|
## Development
|
79
115
|
|
80
116
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "bundler/setup"
|
4
|
-
require "rails
|
4
|
+
require "rails-env-credentials"
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -1,6 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RailsEnvCredentials
|
4
|
+
module CredentialsOverwrite
|
5
|
+
def credentials
|
6
|
+
@credentials ||= RailsEnvCredentials.credentials
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
4
10
|
class Railtie < ::Rails::Railtie
|
5
11
|
config.before_configuration do
|
6
12
|
is_credentials_command = Rails.const_defined?(:Command) &&
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_dependency "rails", ">= 5.2.0.rc1"
|
26
26
|
|
27
|
-
spec.add_development_dependency "bundler", "~>
|
27
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
28
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
29
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
30
|
spec.add_development_dependency "simplecov"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-env-credentials
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sinsoku
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,12 +101,12 @@ files:
|
|
101
101
|
- config/environments/production.rb
|
102
102
|
- config/environments/staging.rb
|
103
103
|
- config/environments/test.rb
|
104
|
+
- gemfiles/rails_52.gemfile
|
104
105
|
- gemfiles/rails_edge.gemfile
|
105
106
|
- lib/rails-env-credentials.rb
|
106
107
|
- lib/rails/commands/env_credentials_command.rb
|
107
108
|
- lib/rails_env_credentials.rb
|
108
109
|
- lib/rails_env_credentials/config.rb
|
109
|
-
- lib/rails_env_credentials/credentials_overwrite.rb
|
110
110
|
- lib/rails_env_credentials/railtie.rb
|
111
111
|
- lib/rails_env_credentials/version.rb
|
112
112
|
- rails-env-credentials.gemspec
|
@@ -129,8 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
|
-
|
133
|
-
rubygems_version: 2.7.6
|
132
|
+
rubygems_version: 3.0.3
|
134
133
|
signing_key:
|
135
134
|
specification_version: 4
|
136
135
|
summary: It enhances the credentials configuration introduced by Rails v5.2.0
|