secretfile 1.0.0 → 1.0.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/CHANGELOG.md +25 -0
- data/Gemfile.lock +1 -1
- data/README.md +18 -0
- data/Secretfile +6 -0
- data/lib/secretfile/version.rb +1 -1
- data/lib/secretfile.rb +24 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1faf0efa8e924c393fe22a8ab42edd2f42a1a91ba9925481efc88cfd9cb02696
|
4
|
+
data.tar.gz: 0d82ca7d5fdd714dcd591106a870831b788ea2a1419827095db333662ac66065
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c702a51fb30e1538d06100265281c12518e60ba74929a93c23315f75296380b6de1838ae1d97097ea4c8e9e7660307feb31b939902eb71574f04b54f5e1fe7ea
|
7
|
+
data.tar.gz: 664b3cf47b240b6bf6cc546969b53e2d2e01366f71aee1ca156a7fdfdeb2a84057ac528c7fd4c5146c57a12578a751015f98de57537df9b531f60355c0505c10
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
1.0.4 / 2021-12-17
|
2
|
+
|
3
|
+
* Enhancements
|
4
|
+
|
5
|
+
* Don't hide fs error if Secretfile not readable
|
6
|
+
|
7
|
+
1.0.3 / 2021-02-24
|
8
|
+
|
9
|
+
* Bug fixes
|
10
|
+
|
11
|
+
* Allow blank lines in Secretfiles
|
12
|
+
|
13
|
+
1.0.2 / 2019-07-24
|
14
|
+
|
15
|
+
* Enhancements
|
16
|
+
|
17
|
+
* A little protection against doing dumb things like nesting Secretfile.group
|
18
|
+
|
19
|
+
1.0.1 / 2019-07-24
|
20
|
+
|
21
|
+
* Enhancements
|
22
|
+
|
23
|
+
* Support Amazon STS with Secretfile.group {}
|
24
|
+
* Support dashes in vault paths
|
25
|
+
|
1
26
|
1.0.0 / 2019-07-24
|
2
27
|
|
3
28
|
Initial release - inspired by https://github.com/erithmetic/secret_garden
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -31,6 +31,11 @@ The initial implementation of Secretfile in ruby was [`secret_garden`](https://g
|
|
31
31
|
<td>Yes - you <code>require 'secret_garden/vault'</code> etc.</td>
|
32
32
|
<td>No - you only get vault, and it's required by default</td>
|
33
33
|
</tr>
|
34
|
+
<tr>
|
35
|
+
<td>Supports dynamic vault secrets (e.g. Amazon STS)?</td>
|
36
|
+
<td>No - they are never refreshed</td>
|
37
|
+
<td>Yes - they are pulled together, but not cached. Use <code>Secretfile.group { Secretfile.get(x); Secretfile.get(y) }</code>.</td>
|
38
|
+
</tr>
|
34
39
|
</Table>
|
35
40
|
|
36
41
|
## Installation
|
@@ -55,6 +60,9 @@ In your Secretfile:
|
|
55
60
|
|
56
61
|
```
|
57
62
|
DATABASE_URL secrets/$VAULT_ENV/database:url
|
63
|
+
AWS_ACCESS_KEY_ID aws/sts/myrole:access_key
|
64
|
+
AWS_SECRET_ACCESS_KEY aws/sts/myrole:secret_key
|
65
|
+
AWS_SESSION_TOKEN aws/sts/myrole:security_token
|
58
66
|
```
|
59
67
|
|
60
68
|
Then you call
|
@@ -63,6 +71,16 @@ Then you call
|
|
63
71
|
Secretfile.get('DATABASE_URL') # looks for ENV['DATABASE_URL'], falling back to secrets/$VAULT_ENV/database:url
|
64
72
|
```
|
65
73
|
|
74
|
+
To use dynamic creds like [Amazon STS](https://docs.aws.amazon.com/STS/latest/APIReference/Welcome.html) with the [Vault AWS Secrets engine](https://www.vaultproject.io/docs/secrets/aws/index.html), do this:
|
75
|
+
|
76
|
+
```
|
77
|
+
Secretfile.group do
|
78
|
+
akid = Secretfile.get('AWS_ACCESS_KEY_ID')
|
79
|
+
sk = Secretfile.get('AWS_SECRET_ACCESS_KEY')
|
80
|
+
st = Secretfile.get('AWS_SESSION_TOKEN')
|
81
|
+
end
|
82
|
+
```
|
83
|
+
|
66
84
|
## Development
|
67
85
|
|
68
86
|
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/Secretfile
CHANGED
@@ -3,3 +3,9 @@
|
|
3
3
|
SECRET1 not/in/vault:set_in_env
|
4
4
|
SECRET2 secret/test:value
|
5
5
|
SECRET3 not/in/vault:expected_to_raise
|
6
|
+
# allow empty lines like the one following this:
|
7
|
+
|
8
|
+
# amazon sts, for example, requires these all to be gotten at once
|
9
|
+
AWS_ACCESS_KEY_ID aws/sts/myrole:access_key
|
10
|
+
AWS_SECRET_ACCESS_KEY aws/sts/myrole:secret_key
|
11
|
+
AWS_SESSION_TOKEN aws/sts/myrole:security_token
|
data/lib/secretfile/version.rb
CHANGED
data/lib/secretfile.rb
CHANGED
@@ -10,12 +10,27 @@ class Secretfile
|
|
10
10
|
def get(k)
|
11
11
|
instance.get k
|
12
12
|
end
|
13
|
+
|
14
|
+
def group
|
15
|
+
begin
|
16
|
+
instance.mutex.synchronize do
|
17
|
+
raise "Can't nest Secretfile.group" if instance.group
|
18
|
+
instance.group = {}
|
19
|
+
end
|
20
|
+
yield
|
21
|
+
ensure
|
22
|
+
instance.group = nil
|
23
|
+
end
|
24
|
+
end
|
13
25
|
end
|
14
26
|
|
15
27
|
attr_reader :spec
|
28
|
+
attr_reader :mutex
|
29
|
+
attr_accessor :group
|
16
30
|
|
17
31
|
def initialize
|
18
32
|
super # singleton magic i guess
|
33
|
+
@mutex = Mutex.new
|
19
34
|
read_spec
|
20
35
|
end
|
21
36
|
|
@@ -28,7 +43,13 @@ class Secretfile
|
|
28
43
|
ENV[k]
|
29
44
|
else
|
30
45
|
path, field = spec.fetch k
|
31
|
-
payload =
|
46
|
+
payload = if group&.has_key?(path)
|
47
|
+
group[path]
|
48
|
+
else
|
49
|
+
memo = Vault.logical.read(path) or raise("Secret #{k.inspect} not found in Vault at #{path}")
|
50
|
+
group[path] = memo if group
|
51
|
+
memo
|
52
|
+
end
|
32
53
|
payload.data[field.to_sym] or raise("Secret #{k.inspect} not found in Vault at #{path}:#{field}")
|
33
54
|
end
|
34
55
|
end
|
@@ -39,11 +60,11 @@ class Secretfile
|
|
39
60
|
ENV.fetch('SECRETFILE_PATH', 'Secretfile')
|
40
61
|
end
|
41
62
|
|
42
|
-
VALID_LINE = /\A\w+\s+[\w
|
63
|
+
VALID_LINE = /\A\w+\s+[\w\-\/]+:\w+\z/
|
43
64
|
def read_spec
|
44
|
-
raise "Expected Secretfile" unless File.readable?(spec_path)
|
45
65
|
@spec = IO.readlines(spec_path).inject({}) do |memo, line|
|
46
66
|
line.chomp!
|
67
|
+
next memo if line =~ /\A\s*\z/
|
47
68
|
next memo if line =~ /\A\s*#/
|
48
69
|
line.gsub!(/\$(\{)?([A-Z0-9_]+)(\})?/) do
|
49
70
|
if $1 == '{' and $3 != '}'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secretfile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seamus Abshere
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.1.6
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Define secret mapping in a Secretfile.
|