nuclear_secrets 1.0.3 → 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/README.md +17 -1
- data/lib/nuclear_secrets.rb +18 -0
- data/lib/nuclear_secrets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dd76875fe74fffcbc470049619b65182ea50625
|
4
|
+
data.tar.gz: 11c2e408eaa6de7be7ee6b2a15036ccab19334fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53c101780a0d2b3d3e1a12aa982b7a47abe13b00bdfd5a5de88461d3ab13397b899d853ea6e0fea7fee91b9c1dec8043fc363b0c7293f30b578bfb8020472bc7
|
7
|
+
data.tar.gz: 0ee7fead105f4bee046a2b637cd0698034fccc9912cdbe8a3738a1c703bf49726f0a7b3abc23d747f17dc68ae3682c028f1f88422e8121085f229ddad78c52bf
|
data/README.md
CHANGED
@@ -35,7 +35,7 @@ In addition to being able to supply NuclearSecrets with the type of a secret,
|
|
35
35
|
you can also pass a Proc or a Lambda. If the proc or lamba returns true when
|
36
36
|
passed the value of the secret, then the secret will be allowed.
|
37
37
|
|
38
|
-
```
|
38
|
+
```ruby
|
39
39
|
NuclearSecrets.configure do |config|
|
40
40
|
config.required_secrets = {
|
41
41
|
my_string_secret: String,
|
@@ -45,6 +45,22 @@ NuclearSecrets.configure do |config|
|
|
45
45
|
end
|
46
46
|
```
|
47
47
|
|
48
|
+
## Settings
|
49
|
+
You can add a settings object in the configure as well:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
NuclearSecrets.configure do |config|
|
53
|
+
config.required_secrets = {
|
54
|
+
...
|
55
|
+
}
|
56
|
+
config.settings = {
|
57
|
+
raise_on_extra_secrets: false,
|
58
|
+
}
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
* `raise_on_extra_secrets`: raises an error when extra secrets are present(defaults to `false`)
|
63
|
+
|
48
64
|
## Contributing
|
49
65
|
Contribution directions go here.
|
50
66
|
|
data/lib/nuclear_secrets.rb
CHANGED
@@ -1,14 +1,27 @@
|
|
1
1
|
require "nuclear_secrets/engine"
|
2
2
|
require "nuclear_secrets/errors"
|
3
|
+
require "logger"
|
3
4
|
|
4
5
|
module NuclearSecrets
|
5
6
|
class << self
|
6
7
|
attr_accessor(:required_secrets)
|
8
|
+
attr_accessor(:settings)
|
7
9
|
|
8
10
|
def configure
|
9
11
|
yield self if block_given?
|
10
12
|
end
|
11
13
|
|
14
|
+
def init_settings
|
15
|
+
@settings = {} unless @settings.is_a? Hash
|
16
|
+
@settings = default_settings.merge(@settings)
|
17
|
+
end
|
18
|
+
|
19
|
+
def default_settings
|
20
|
+
{
|
21
|
+
raise_on_extra_secrets: false,
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
12
25
|
def make_type_check(type)
|
13
26
|
Proc.new { |item| item.class == type }
|
14
27
|
end
|
@@ -58,6 +71,8 @@ module NuclearSecrets
|
|
58
71
|
end
|
59
72
|
|
60
73
|
def check_secrets(secrets)
|
74
|
+
logger = Logger.new(STDOUT)
|
75
|
+
init_settings
|
61
76
|
raise NuclearSecrets::RequiredSecretsListMissing if required_secrets.nil?
|
62
77
|
req_keys = required_secrets.keys
|
63
78
|
existing_keys = secrets.keys
|
@@ -73,6 +88,9 @@ module NuclearSecrets
|
|
73
88
|
assertions = build_assertions(secrets, existing_keys)
|
74
89
|
error_pairs = check_assertions(secrets, assertions)
|
75
90
|
raise MismatchedSecretType.new(error_pairs) if !error_pairs.empty?
|
91
|
+
rescue ExtraSecretsError => e
|
92
|
+
logger.warn e.message
|
93
|
+
raise e if @settings[:raise_on_extra_secrets] == true
|
76
94
|
end
|
77
95
|
end
|
78
96
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nuclear_secrets
|
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
|
- Atomic Jolt
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-03
|
12
|
+
date: 2018-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|