legion-crypt 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +15 -39
- data/.rubocop.yml +4 -12
- data/Gemfile.lock +46 -61
- data/bitbucket-pipelines.yml +1 -2
- data/legion-crypt.gemspec +3 -3
- data/lib/legion/crypt/cipher.rb +19 -10
- data/lib/legion/crypt/settings.rb +20 -14
- data/lib/legion/crypt/vault.rb +11 -8
- data/lib/legion/crypt/version.rb +1 -1
- metadata +10 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 265bfefa35f6346031ae28749fa479e511e9f98f5a3c8b5cd3b756e86f6920b4
|
4
|
+
data.tar.gz: 2fedcd11ffcb04683cdf8c122b721bd30e37b7a73b48f2660237895725045999
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 430546afd08fdddbc359be8dd09a530552a596917943ca7e5c0a9bd7a3064e4c95cbb3ea468faaa62cfe6572577eea3eb60765ebbb68f3a8756a0a491de8c44d
|
7
|
+
data.tar.gz: 856f677b6201f8052cf6d0a617f56ce893029afc02df2f9490e506bc55034090814f35cf0c98438c66db6c0a728be84f060f72c7319bb20bfd29f0cc1debdc24
|
data/.circleci/config.yml
CHANGED
@@ -10,7 +10,7 @@ jobs:
|
|
10
10
|
steps:
|
11
11
|
- checkout
|
12
12
|
- restore_cache:
|
13
|
-
key: "bundler
|
13
|
+
key: "bundler cache mri"
|
14
14
|
- run: bundle update
|
15
15
|
- run: bundle exec rubocop --format=json --out=rubocop-result.json
|
16
16
|
- store_test_results:
|
@@ -18,24 +18,21 @@ jobs:
|
|
18
18
|
- sonarcloud/scan
|
19
19
|
- run: bundle exec rubocop
|
20
20
|
- save_cache:
|
21
|
-
key: "bundler
|
21
|
+
key: "bundler cache mri"
|
22
22
|
paths:
|
23
23
|
- "/usr/local/bundle"
|
24
|
-
- "/home/circleci/.rubygems"
|
25
24
|
"ruby-two-five":
|
26
25
|
docker:
|
27
26
|
- image: cimg/ruby:2.5
|
28
|
-
- image: rabbitmq:3.7
|
29
27
|
steps:
|
30
28
|
- checkout
|
31
29
|
- restore_cache:
|
32
|
-
key: "bundler
|
30
|
+
key: "bundler cache mri"
|
33
31
|
- run: bundle update
|
34
32
|
- save_cache:
|
35
|
-
key: "bundler
|
33
|
+
key: "bundler cache mri"
|
36
34
|
paths:
|
37
35
|
- "/usr/local/bundle"
|
38
|
-
- "/home/circleci/.rubygems"
|
39
36
|
- run: bundle exec rspec --format progress --format RspecJunitFormatter -o rspec-results.xml
|
40
37
|
- store_test_results:
|
41
38
|
path: rspec-results.xml
|
@@ -43,17 +40,15 @@ jobs:
|
|
43
40
|
"ruby-two-six":
|
44
41
|
docker:
|
45
42
|
- image: cimg/ruby:2.6
|
46
|
-
- image: rabbitmq:3.7
|
47
43
|
steps:
|
48
44
|
- checkout
|
49
45
|
- restore_cache:
|
50
|
-
key: "bundler
|
46
|
+
key: "bundler cache mri"
|
51
47
|
- run: bundle update
|
52
48
|
- save_cache:
|
53
|
-
key: "bundler
|
49
|
+
key: "bundler cache mri"
|
54
50
|
paths:
|
55
51
|
- "/usr/local/bundle"
|
56
|
-
- "/home/circleci/.rubygems"
|
57
52
|
- run: bundle exec rspec --format progress --format RspecJunitFormatter -o rspec-results.xml
|
58
53
|
- store_test_results:
|
59
54
|
path: rspec-results.xml
|
@@ -61,53 +56,31 @@ jobs:
|
|
61
56
|
"ruby-two-seven":
|
62
57
|
docker:
|
63
58
|
- image: circleci/ruby:2.7
|
64
|
-
- image: rabbitmq:3.7
|
65
59
|
steps:
|
66
60
|
- checkout
|
67
61
|
- restore_cache:
|
68
|
-
key: "bundler
|
62
|
+
key: "bundler cache mri"
|
69
63
|
- run: bundle update
|
70
64
|
- save_cache:
|
71
|
-
key: "bundler
|
65
|
+
key: "bundler cache mri"
|
72
66
|
paths:
|
73
67
|
- "/usr/local/bundle"
|
74
|
-
- "/home/circleci/.rubygems"
|
75
68
|
- run: bundle exec rspec --format progress --format RspecJunitFormatter -o rspec-results.xml
|
76
69
|
- store_test_results:
|
77
70
|
path: rspec-results.xml
|
78
71
|
- sonarcloud/scan
|
79
|
-
"
|
72
|
+
"ruby-three":
|
80
73
|
docker:
|
81
|
-
- image: circleci/
|
82
|
-
- image: rabbitmq:3.7
|
74
|
+
- image: circleci/ruby:3
|
83
75
|
steps:
|
84
76
|
- checkout
|
85
77
|
- restore_cache:
|
86
|
-
key: "bundler cache
|
78
|
+
key: "bundler cache mri"
|
87
79
|
- run: bundle update
|
88
80
|
- save_cache:
|
89
|
-
key: "bundler cache
|
81
|
+
key: "bundler cache mri"
|
90
82
|
paths:
|
91
83
|
- "/usr/local/bundle"
|
92
|
-
- "/home/circleci/.rubygems"
|
93
|
-
- run: bundle exec rspec --format progress --format RspecJunitFormatter -o rspec-results.xml
|
94
|
-
- store_test_results:
|
95
|
-
path: rspec-results.xml
|
96
|
-
- sonarcloud/scan
|
97
|
-
"jruby92-14jdk":
|
98
|
-
docker:
|
99
|
-
- image: circleci/jruby:9.2-jdk14
|
100
|
-
- image: rabbitmq:3.7
|
101
|
-
steps:
|
102
|
-
- checkout
|
103
|
-
- restore_cache:
|
104
|
-
key: "bundler cache jruby92-14jdk"
|
105
|
-
- run: bundle update
|
106
|
-
- save_cache:
|
107
|
-
key: "bundler cache jruby92-14jdk"
|
108
|
-
paths:
|
109
|
-
- "/usr/local/bundle"
|
110
|
-
- "/home/circleci/.rubygems"
|
111
84
|
- run: bundle exec rspec --format progress --format RspecJunitFormatter -o rspec-results.xml
|
112
85
|
- store_test_results:
|
113
86
|
path: rspec-results.xml
|
@@ -125,5 +98,8 @@ workflows:
|
|
125
98
|
requires:
|
126
99
|
- ruby-two-five
|
127
100
|
- ruby-two-seven:
|
101
|
+
requires:
|
102
|
+
- ruby-two-five
|
103
|
+
- ruby-three:
|
128
104
|
requires:
|
129
105
|
- ruby-two-five
|
data/.rubocop.yml
CHANGED
@@ -7,26 +7,18 @@ Metrics/ClassLength:
|
|
7
7
|
Metrics/BlockLength:
|
8
8
|
Max: 50
|
9
9
|
Metrics/CyclomaticComplexity:
|
10
|
-
Max:
|
10
|
+
Max: 14
|
11
11
|
Metrics/AbcSize:
|
12
|
-
Max:
|
12
|
+
Max: 17
|
13
13
|
Metrics/PerceivedComplexity:
|
14
|
-
Max:
|
14
|
+
Max: 16
|
15
15
|
Naming/MethodParameterName:
|
16
16
|
Enabled: false
|
17
|
-
Layout/SpaceAroundEqualsInParameterDefault:
|
18
|
-
EnforcedStyle: space
|
19
|
-
Style/SymbolArray:
|
20
|
-
Enabled: true
|
21
|
-
Layout/HashAlignment:
|
22
|
-
EnforcedHashRocketStyle: table
|
23
|
-
EnforcedColonStyle: table
|
24
17
|
Style/Documentation:
|
25
18
|
Enabled: false
|
26
19
|
AllCops:
|
27
20
|
TargetRubyVersion: 2.5
|
28
21
|
NewCops: enable
|
22
|
+
SuggestExtensions: false
|
29
23
|
Style/FrozenStringLiteralComment:
|
30
24
|
Enabled: false
|
31
|
-
Naming/FileName:
|
32
|
-
Enabled: false
|
data/Gemfile.lock
CHANGED
@@ -1,119 +1,106 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
legion-crypt (0.2.
|
5
|
-
vault
|
4
|
+
legion-crypt (0.2.4)
|
5
|
+
vault (>= 0.15.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
amq-protocol (2.3.2)
|
11
|
-
ast (2.4.
|
11
|
+
ast (2.4.2)
|
12
12
|
aws-eventstream (1.1.0)
|
13
13
|
aws-sigv4 (1.2.2)
|
14
14
|
aws-eventstream (~> 1, >= 1.0.2)
|
15
15
|
bunny (2.17.0)
|
16
16
|
amq-protocol (~> 2.3, >= 2.3.1)
|
17
|
-
concurrent-ruby (1.1.
|
18
|
-
concurrent-ruby-ext (1.1.
|
19
|
-
concurrent-ruby (= 1.1.
|
17
|
+
concurrent-ruby (1.1.8)
|
18
|
+
concurrent-ruby-ext (1.1.8)
|
19
|
+
concurrent-ruby (= 1.1.8)
|
20
20
|
connection_pool (2.2.3)
|
21
21
|
daemons (1.3.1)
|
22
22
|
dalli (2.7.11)
|
23
23
|
diff-lcs (1.4.4)
|
24
|
-
docile (1.3.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
legion-cache (1.1.0)
|
24
|
+
docile (1.3.5)
|
25
|
+
json (2.5.1)
|
26
|
+
json_pure (2.5.1)
|
27
|
+
legion-cache (1.1.1)
|
29
28
|
connection_pool (>= 2.2.3)
|
30
29
|
dalli (>= 2.7)
|
31
30
|
redis (>= 4.2)
|
32
|
-
legion-
|
33
|
-
|
34
|
-
legion-data (1.1.5)
|
35
|
-
legion-logging
|
36
|
-
legion-settings
|
37
|
-
mysql2
|
38
|
-
sequel
|
39
|
-
legion-exceptions (1.1.4)
|
40
|
-
legion-json (1.1.3)
|
31
|
+
legion-exceptions (1.1.5)
|
32
|
+
legion-json (1.1.4)
|
41
33
|
json_pure
|
34
|
+
legion-exceptions (>= 1.1.5)
|
42
35
|
multi_json
|
43
|
-
legion-logging (1.1.
|
36
|
+
legion-logging (1.1.4)
|
44
37
|
rainbow (~> 3)
|
45
|
-
legion-settings (1.1.
|
38
|
+
legion-settings (1.1.3)
|
46
39
|
legion-json
|
47
40
|
legion-logging
|
48
|
-
legion-transport (1.1.
|
49
|
-
bunny
|
50
|
-
concurrent-ruby
|
41
|
+
legion-transport (1.1.9)
|
42
|
+
bunny (>= 2.17.0)
|
43
|
+
concurrent-ruby (>= 1.1.7)
|
51
44
|
legion-json
|
52
|
-
legionio (0.
|
53
|
-
|
54
|
-
concurrent-ruby
|
55
|
-
|
56
|
-
daemons
|
57
|
-
hashdiff
|
45
|
+
legionio (0.4.2)
|
46
|
+
concurrent-ruby (>= 1.1.7)
|
47
|
+
concurrent-ruby-ext (>= 1.1.7)
|
48
|
+
daemons (>= 1.3.1)
|
58
49
|
legion-cache
|
59
|
-
legion-
|
60
|
-
legion-crypt
|
61
|
-
legion-data
|
50
|
+
legion-crypt (>= 0.2.0)
|
62
51
|
legion-exceptions
|
63
52
|
legion-json
|
64
53
|
legion-logging
|
65
54
|
legion-settings
|
66
|
-
legion-transport
|
55
|
+
legion-transport (>= 1.1.9)
|
67
56
|
lex-node
|
68
|
-
oj
|
69
|
-
|
57
|
+
oj (>= 3.10)
|
58
|
+
thor (>= 1)
|
59
|
+
lex-node (0.1.4)
|
70
60
|
multi_json (1.15.0)
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
parser (2.7.2.0)
|
61
|
+
oj (3.11.2)
|
62
|
+
parallel (1.20.1)
|
63
|
+
parser (3.0.0.0)
|
75
64
|
ast (~> 2.4.1)
|
76
65
|
rainbow (3.0.0)
|
77
|
-
|
78
|
-
|
79
|
-
regexp_parser (1.8.2)
|
66
|
+
redis (4.2.5)
|
67
|
+
regexp_parser (2.1.1)
|
80
68
|
rexml (3.2.4)
|
81
69
|
rspec (3.10.0)
|
82
70
|
rspec-core (~> 3.10.0)
|
83
71
|
rspec-expectations (~> 3.10.0)
|
84
72
|
rspec-mocks (~> 3.10.0)
|
85
|
-
rspec-core (3.10.
|
73
|
+
rspec-core (3.10.1)
|
86
74
|
rspec-support (~> 3.10.0)
|
87
|
-
rspec-expectations (3.10.
|
75
|
+
rspec-expectations (3.10.1)
|
88
76
|
diff-lcs (>= 1.2.0, < 2.0)
|
89
77
|
rspec-support (~> 3.10.0)
|
90
|
-
rspec-mocks (3.10.
|
78
|
+
rspec-mocks (3.10.2)
|
91
79
|
diff-lcs (>= 1.2.0, < 2.0)
|
92
80
|
rspec-support (~> 3.10.0)
|
93
|
-
rspec-support (3.10.
|
81
|
+
rspec-support (3.10.2)
|
94
82
|
rspec_junit_formatter (0.4.1)
|
95
83
|
rspec-core (>= 2, < 4, != 2.12.0)
|
96
|
-
rubocop (1.
|
84
|
+
rubocop (1.11.0)
|
97
85
|
parallel (~> 1.10)
|
98
|
-
parser (>=
|
86
|
+
parser (>= 3.0.0.0)
|
99
87
|
rainbow (>= 2.2.2, < 4.0)
|
100
|
-
regexp_parser (>= 1.8)
|
88
|
+
regexp_parser (>= 1.8, < 3.0)
|
101
89
|
rexml
|
102
|
-
rubocop-ast (>= 1.0.
|
90
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
103
91
|
ruby-progressbar (~> 1.7)
|
104
|
-
unicode-display_width (>= 1.4.0, <
|
105
|
-
rubocop-ast (1.
|
92
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
93
|
+
rubocop-ast (1.4.1)
|
106
94
|
parser (>= 2.7.1.5)
|
107
|
-
ruby-progressbar (1.
|
108
|
-
sequel (5.38.0)
|
95
|
+
ruby-progressbar (1.11.0)
|
109
96
|
simplecov (0.17.1)
|
110
97
|
docile (~> 1.1)
|
111
98
|
json (>= 1.8, < 3)
|
112
99
|
simplecov-html (~> 0.10.0)
|
113
100
|
simplecov-html (0.10.2)
|
114
101
|
simplecov_json_formatter (0.1.2)
|
115
|
-
thor (1.0
|
116
|
-
unicode-display_width (
|
102
|
+
thor (1.1.0)
|
103
|
+
unicode-display_width (2.0.0)
|
117
104
|
vault (0.15.0)
|
118
105
|
aws-sigv4
|
119
106
|
|
@@ -121,13 +108,11 @@ PLATFORMS
|
|
121
108
|
ruby
|
122
109
|
|
123
110
|
DEPENDENCIES
|
124
|
-
bundler (>= 2)
|
125
111
|
legion-crypt!
|
126
112
|
legion-logging
|
127
113
|
legion-settings
|
128
114
|
legion-transport
|
129
115
|
legionio
|
130
|
-
rake
|
131
116
|
rspec
|
132
117
|
rspec_junit_formatter
|
133
118
|
rubocop
|
@@ -135,4 +120,4 @@ DEPENDENCIES
|
|
135
120
|
simplecov_json_formatter
|
136
121
|
|
137
122
|
BUNDLED WITH
|
138
|
-
2.
|
123
|
+
2.2.6
|
data/bitbucket-pipelines.yml
CHANGED
@@ -7,8 +7,7 @@ pipelines:
|
|
7
7
|
name: Push to RubyGems
|
8
8
|
deployment: RubyGems
|
9
9
|
script:
|
10
|
-
- gem install
|
11
|
-
- bundle install
|
10
|
+
- gem install gem-release
|
12
11
|
- (umask 077 ; echo $gem_creds | base64 --decode > ~/.gem/credentials)
|
13
12
|
- gem release
|
14
13
|
artifacts:
|
data/legion-crypt.gemspec
CHANGED
@@ -17,20 +17,20 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.metadata['homepage_uri'] = spec.homepage
|
18
18
|
spec.metadata['source_code_uri'] = 'https://bitbucket.org/legion-io/legion/'
|
19
19
|
spec.metadata['changelog_uri'] = 'https://bitbucket.org/legion-io/legion/src/master/CHANGELOG.md'
|
20
|
+
spec.metadata['wiki_uri'] = 'https://bitbucket.org/legion-io/legion-crypt/wiki'
|
21
|
+
spec.metadata['bug_tracker_uri'] = 'https://bitbucket.org/legion-io/legion-crypt/issues'
|
20
22
|
|
21
23
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
24
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
25
|
end
|
24
26
|
spec.require_paths = ['lib']
|
25
27
|
|
26
|
-
spec.add_dependency 'vault'
|
28
|
+
spec.add_dependency 'vault', '>= 0.15.0'
|
27
29
|
|
28
|
-
spec.add_development_dependency 'bundler', '>= 2'
|
29
30
|
spec.add_development_dependency 'legionio'
|
30
31
|
spec.add_development_dependency 'legion-logging'
|
31
32
|
spec.add_development_dependency 'legion-settings'
|
32
33
|
spec.add_development_dependency 'legion-transport'
|
33
|
-
spec.add_development_dependency 'rake'
|
34
34
|
spec.add_development_dependency 'rspec'
|
35
35
|
spec.add_development_dependency 'rspec_junit_formatter'
|
36
36
|
spec.add_development_dependency 'rubocop'
|
data/lib/legion/crypt/cipher.rb
CHANGED
@@ -48,10 +48,10 @@ module Legion
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def cs
|
51
|
-
@cs ||= Digest::SHA256.digest
|
51
|
+
@cs ||= Digest::SHA256.digest(fetch_cs)
|
52
52
|
end
|
53
53
|
|
54
|
-
def fetch_cs # rubocop:disable Metrics/AbcSize
|
54
|
+
def fetch_cs # rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity
|
55
55
|
if Legion::Settings[:crypt][:vault][:read_cluster_secret] && Legion::Settings[:crypt][:vault][:connected] && Legion::Crypt.exist?('crypt') # rubocop:disable Layout/LineLength
|
56
56
|
Legion::Crypt.get('crypt')[:cluster_secret]
|
57
57
|
elsif Legion::Settings[:crypt][:cluster_secret].is_a? String
|
@@ -68,22 +68,31 @@ module Legion
|
|
68
68
|
sleep(sleep_time)
|
69
69
|
sleep_time *= 2 unless sleep_time > 0.5
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
|
+
if Legion::Settings[:crypt][:cluster_secret].nil?
|
73
|
+
Legion::Logging.warn 'Cluster secret is still nil'
|
74
|
+
else
|
72
75
|
Legion::Logging.info "Received cluster secret in #{((Time.new - start) * 1000.0).round}ms"
|
73
76
|
end
|
74
|
-
Legion::Logging.warn 'Cluster secret is still nil' if Legion::Settings[:crypt][:cluster_secret].nil?
|
75
|
-
else
|
76
|
-
Legion::Settings[:crypt][:cluster_secret] = generate_secure_random
|
77
77
|
end
|
78
|
-
Legion::Settings[:crypt][:cs_encrypt_ready] = true
|
79
|
-
Legion::Settings[:crypt][:cluster_secret]
|
80
78
|
rescue StandardError => e
|
81
79
|
Legion::Logging.error(e.message)
|
82
80
|
Legion::Logging.error(e.backtrace)
|
81
|
+
ensure
|
82
|
+
Legion::Settings[:crypt][:cluster_secret] = generate_secure_random unless Legion::Settings[:crypt].key? :cluster_secret
|
83
|
+
nil if Legion::Settings[:crypt][:cluster_secret].nil?
|
83
84
|
|
84
|
-
Legion::Settings[:crypt][:cluster_secret] = generate_secure_random
|
85
85
|
Legion::Settings[:crypt][:cs_encrypt_ready] = true
|
86
|
-
Legion::Settings[:crypt][:
|
86
|
+
push_cs_to_vault if Legion::Settings[:crypt][:vault][:push_cs_to_vault]
|
87
|
+
|
88
|
+
return Legion::Settings[:crypt][:cluster_secret] # rubocop:disable Lint/EnsureReturn
|
89
|
+
end
|
90
|
+
|
91
|
+
def push_cs_to_vault
|
92
|
+
return false unless Legion::Settings[:crypt][:vault][:connected] && Legion::Settings[:crypt][:cluster_secret]
|
93
|
+
|
94
|
+
Legion::Logging.info 'Pushing Cluster Secret to Vault'
|
95
|
+
Legion::Crypt.write('cluster', secret: Legion::Settings[:crypt][:cluster_secret])
|
87
96
|
end
|
88
97
|
|
89
98
|
def generate_secure_random
|
@@ -3,10 +3,10 @@ module Legion
|
|
3
3
|
module Settings
|
4
4
|
def self.default
|
5
5
|
{
|
6
|
-
vault:
|
6
|
+
vault: vault,
|
7
7
|
cs_encrypt_ready: false,
|
8
|
-
dynamic_keys:
|
9
|
-
cluster_secret:
|
8
|
+
dynamic_keys: true,
|
9
|
+
cluster_secret: nil,
|
10
10
|
save_private_key: true,
|
11
11
|
read_private_key: true
|
12
12
|
}
|
@@ -14,16 +14,17 @@ module Legion
|
|
14
14
|
|
15
15
|
def self.vault
|
16
16
|
{
|
17
|
-
enabled:
|
18
|
-
protocol:
|
19
|
-
address:
|
20
|
-
port:
|
21
|
-
token:
|
22
|
-
connected:
|
23
|
-
renewer_time:
|
24
|
-
renewer:
|
17
|
+
enabled: !Gem::Specification.find_by_name('vault').nil?,
|
18
|
+
protocol: 'http',
|
19
|
+
address: 'localhost',
|
20
|
+
port: 8200,
|
21
|
+
token: ENV['VAULT_DEV_ROOT_TOKEN_ID'] || ENV['VAULT_TOKEN_ID'] || nil,
|
22
|
+
connected: false,
|
23
|
+
renewer_time: 5,
|
24
|
+
renewer: true,
|
25
25
|
push_cluster_secret: true,
|
26
|
-
read_cluster_secret: true
|
26
|
+
read_cluster_secret: true,
|
27
|
+
kv_path: ENV['LEGION_VAULT_KV_PATH'] || 'legion'
|
27
28
|
}
|
28
29
|
end
|
29
30
|
end
|
@@ -33,6 +34,11 @@ end
|
|
33
34
|
begin
|
34
35
|
Legion::Settings.merge_settings('crypt', Legion::Crypt::Settings.default) if Legion.const_defined?('Settings')
|
35
36
|
rescue StandardError => e
|
36
|
-
Legion
|
37
|
-
|
37
|
+
if Legion.const_defined?('Logging') && Legion::Logging.method_defined?(:fatal)
|
38
|
+
Legion::Logging.fatal(e.message)
|
39
|
+
Legion::Logging.fatal(e.backtrace)
|
40
|
+
else
|
41
|
+
puts e.message
|
42
|
+
puts e.backtrace
|
43
|
+
end
|
38
44
|
end
|
data/lib/legion/crypt/vault.rb
CHANGED
@@ -36,20 +36,18 @@ module Legion
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def get(path)
|
39
|
-
result = ::Vault.kv(
|
39
|
+
result = ::Vault.kv(settings[:vault][:kv_path]).read(path)
|
40
40
|
return nil if result.nil?
|
41
41
|
|
42
42
|
result.data
|
43
43
|
end
|
44
44
|
|
45
|
-
def write(path,
|
46
|
-
hash
|
47
|
-
hash[key.to_sym] = value
|
48
|
-
::Vault.kv('legion').write(path, **hash)
|
45
|
+
def write(path, **hash)
|
46
|
+
::Vault.kv(settings[:vault][:kv_path]).write(path, **hash)
|
49
47
|
end
|
50
48
|
|
51
49
|
def exist?(path)
|
52
|
-
!::Vault.kv(
|
50
|
+
!::Vault.kv(settings[:vault][:kv_path]).read_metadata(path).nil?
|
53
51
|
end
|
54
52
|
|
55
53
|
def add_session(path:)
|
@@ -57,9 +55,10 @@ module Legion
|
|
57
55
|
end
|
58
56
|
|
59
57
|
def close_sessions
|
60
|
-
Legion::Logging.info 'Closing all Legion::Crypt vault sessions'
|
61
58
|
return if @sessions.nil?
|
62
59
|
|
60
|
+
Legion::Logging.info 'Closing all Legion::Crypt vault sessions'
|
61
|
+
|
63
62
|
@sessions.each do |session|
|
64
63
|
close_session(session: session)
|
65
64
|
end
|
@@ -69,7 +68,7 @@ module Legion
|
|
69
68
|
return unless Legion::Settings[:crypt][:vault][:connected]
|
70
69
|
return if @renewer.nil?
|
71
70
|
|
72
|
-
Legion::Logging.debug '
|
71
|
+
Legion::Logging.debug 'Shutting down Legion::Crypt::Vault::Renewer'
|
73
72
|
@renewer.cancel
|
74
73
|
end
|
75
74
|
|
@@ -86,6 +85,10 @@ module Legion
|
|
86
85
|
renew_session(session: session)
|
87
86
|
end
|
88
87
|
end
|
88
|
+
|
89
|
+
def vault_exists?(name)
|
90
|
+
::Vault.sys.mounts.key?(name.to_sym)
|
91
|
+
end
|
89
92
|
end
|
90
93
|
end
|
91
94
|
end
|
data/lib/legion/crypt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legion-crypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esity
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: vault
|
@@ -16,28 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.15.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '2'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '2'
|
26
|
+
version: 0.15.0
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: legionio
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,20 +80,6 @@ dependencies:
|
|
94
80
|
- - ">="
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rake
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
83
|
- !ruby/object:Gem::Dependency
|
112
84
|
name: rspec
|
113
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,7 +183,9 @@ metadata:
|
|
211
183
|
homepage_uri: https://bitbucket.org/legion-io/legion-vault/
|
212
184
|
source_code_uri: https://bitbucket.org/legion-io/legion/
|
213
185
|
changelog_uri: https://bitbucket.org/legion-io/legion/src/master/CHANGELOG.md
|
214
|
-
|
186
|
+
wiki_uri: https://bitbucket.org/legion-io/legion-crypt/wiki
|
187
|
+
bug_tracker_uri: https://bitbucket.org/legion-io/legion-crypt/issues
|
188
|
+
post_install_message:
|
215
189
|
rdoc_options: []
|
216
190
|
require_paths:
|
217
191
|
- lib
|
@@ -226,8 +200,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
200
|
- !ruby/object:Gem::Version
|
227
201
|
version: '0'
|
228
202
|
requirements: []
|
229
|
-
rubygems_version: 3.
|
230
|
-
signing_key:
|
203
|
+
rubygems_version: 3.2.6
|
204
|
+
signing_key:
|
231
205
|
specification_version: 4
|
232
206
|
summary: Legion::Vault is used to keep things safe
|
233
207
|
test_files: []
|