sanctum 0.8.5.rc2 → 0.8.5.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6dc55aef33e0ba6113e5577b80799818e64a8953d0643d6b029335b84a5edc23
4
- data.tar.gz: 52638d7d39ccb21cb830288081d9ca23017e3582e991603ec8f084175f0f3034
3
+ metadata.gz: b9644d3be1fdfcdd2e01ea42a1a0abd2e695bd3b2e9fe156083b10f64fb61540
4
+ data.tar.gz: 6b467122d7066368cf662a37c00f7d9bad88e7c4e1d9aabbb7dc12d54fed70cc
5
5
  SHA512:
6
- metadata.gz: 475976714b4229cd2e9a4dce401ed6aada1decbb2da6e73f55e7de3ba95e8ea17ef0aa0e4b84be9225713d8cacfe2260236b75cc75e21d396bcb6d63403463f5
7
- data.tar.gz: 16b9465d78eeceb1580c8203eb8c21096d6a398d3b2c6c023f8c4e68bbfbe698c21be2cc9f52daf81175d35706f2a95b89a07214ccba1f4dde38ed7ef4303e8e
6
+ metadata.gz: 4b8f3ecbae4f6085c442ff12aa87560d884016a1bae709e7110a6a766d53b133986b148ccb69772acf2d3eb2ddba77c26a0305e41992f5e319ad4a485fe666ee
7
+ data.tar.gz: 9f081fb88da05525f0666a05994a2299136e1f52c37d2979607849dd4db752cb71e15802ac3cdbfeffc515c6f57aba73a1d91c7c32fa8e703f4d667bca0abbd0
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sanctum (0.8.5.rc2)
4
+ sanctum (0.8.5.rc3)
5
5
  gli (~> 2.18)
6
6
  hashdiff (~> 0.3)
7
7
  vault (~> 0.12)
data/README.md CHANGED
@@ -4,7 +4,11 @@ Local files are encrypted using vaults [transit](https://www.vaultproject.io/api
4
4
  This makes maintaining multiple vault secrets for multiple applications simple and secure.
5
5
 
6
6
  ## Usage Example
7
- Lets say you have a vault instance with a `generic`, or `kv` enabled backend.
7
+
8
+ ### Generic/KV API v1
9
+ **NOTE: If you just starting to use sanctum, and or vault, you should be using API v2 For more info see, [Vault kv v2](https://www.vaultproject.io/docs/secrets/kv/kv-v2.html), or [Vault kv v1](https://www.vaultproject.io/docs/secrets/kv/kv-v1.html)**
10
+
11
+ Lets say you have a vault instance with a `generic`, or `kv v1` enabled backend.
8
12
  if you were to run, `vault read secrets/cool-app/dev/env` you would see something similar to
9
13
 
10
14
  ```
@@ -23,6 +27,37 @@ using the sanctum gem, you could run `sanctum pull`. Depending on the path you s
23
27
  `env` would contain a `transit` encrypted base64 encoded blob, which you could then edit with `sanctum edit <path-specified>/cool-app/dev/env`. You could then push any changes with
24
28
  `sanctum push`.
25
29
 
30
+ ### KV API v2
31
+ **NOTE: V2 API adds `/data` and `/metadata` endpoints as such sanctum will automatically add `/data` to your local path in order to reflect the endpoints see [Vault kv v2](https://www.vaultproject.io/docs/secrets/kv/kv-v2.html)**
32
+
33
+ Lets say you have a vault instance with `kv v2` enabled backend.
34
+ if you were to run, `vault kv secrets/cool-app/dev/env` you may see something similar to
35
+
36
+ ```
37
+ ====== Metadata ======
38
+ Key Value
39
+ --- -----
40
+ created_time 2019-02-17T00:58:51.194452314Z
41
+ deletion_time n/a
42
+ destroyed false
43
+ version 1
44
+
45
+ ======= Data =======
46
+ Key Value
47
+ --- -----
48
+ db_password heydudeihaveacoolapp
49
+ token myrandomtoken
50
+
51
+ ```
52
+
53
+ using the sanctum gem, you could run `sanctum pull`. Depending on the path you specified in the `sanctum.yaml` config file; Your local file system would look similar to
54
+ ```
55
+ <path-specified>/data/cool-app/dev/env
56
+ ```
57
+
58
+ `env` would contain a `transit` encrypted base64 encoded blob, which you could then edit with `sanctum edit <path-specified>/data/cool-app/dev/env`. You could then push any changes with
59
+ `sanctum push`.
60
+
26
61
  ## Installation
27
62
 
28
63
  From source:
@@ -42,7 +77,7 @@ sanctum config - Generate an example config file.
42
77
  sanctum create - Create an encrypted local file.
43
78
  sanctum edit - Edit an encrypted local file.
44
79
  sanctum view - View an encrypted local file.
45
- sanctum update - Update secrets backend to v2 api.
80
+ sanctum update - Update secrets backend to v2 API.
46
81
  ```
47
82
 
48
83
 
@@ -81,8 +116,8 @@ The configuration file is a Hash represented in YAML format with three possible
81
116
  * At lease one application/target definition is required.
82
117
 
83
118
  ## Roadmap
84
- * <strike>Add vault v2 api support</strike>
85
- * <strike>Add upgrade option for v2 api</strike>
119
+ * <strike>Add vault v2 API support</strike>
120
+ * <strike>Add upgrade option for v2 API</strike>
86
121
  * If transit key doesn't exist try to create it(automatically)
87
122
  * If secrets mount doesn't exist try to create it(automatically)
88
123
  * <strike>Better/more Tests</strike>
@@ -17,8 +17,14 @@ module Sanctum
17
17
  @args = args
18
18
 
19
19
  @transit_key = options.fetch(:vault).fetch(:transit_key)
20
- # TODO: Fix, to much is happening to targets in this initializer!
21
- @targets = update_prefix_or_path(set_secrets_version(options.fetch(:sync)))
20
+ # TODO: Fix, way to much is happening to targets in this initializer!
21
+ @targets = update_prefix_or_path(
22
+ set_secrets_version(
23
+ remove_trailing_slash(
24
+ options.fetch(:sync)
25
+ )
26
+ )
27
+ )
22
28
  @config_file = options.fetch(:config_file)
23
29
  end
24
30
 
@@ -46,19 +52,23 @@ module Sanctum
46
52
  mounts_hash = mounts_info
47
53
 
48
54
  targets.each do |h|
49
- next if h.key?(:secrets_version)
55
+ if h.key?(:secrets_version)
56
+ # Ensure value is a string
57
+ h[:secrets_version] = h[:secrets_version].to_s
58
+ next
59
+ end
50
60
 
51
61
  # If mount options is nil default to api version 1 otherwise use version value
52
62
  # generic mounts will not have a version specified
53
63
  if mounts_hash.dig(:data, :secret, "#{h[:prefix]}/".to_sym, :options).nil?
54
64
  h[:secrets_version] = "1"
55
65
  else
56
- h[:secrets_version] = mounts_hash.dig(:data, :secret, "#{h[:prefix]}/".to_sym, :options, :version)
66
+ h[:secrets_version] = mounts_hash.dig(:data, :secret, "#{h[:prefix]}/".to_sym, :options, :version).to_s
57
67
  end
58
68
  end
59
69
  end
60
70
 
61
- # Internal, add /data to prefix or path if secrets_version == "2"
71
+ # Internal, update prefix or path, add `/data` if secrets_version == "2"
62
72
  # Parameter is an array of hashes: [{}, {}]
63
73
  # Returns array of hashes: [{:name=>"vault-test", :prefix=>"vault-test/data", :path=>"vault/vault-test/data", :secrets_version=>"2"},{}]
64
74
  def update_prefix_or_path(targets)
@@ -70,6 +80,13 @@ module Sanctum
70
80
  end
71
81
  end
72
82
 
83
+ def remove_trailing_slash(targets)
84
+ targets.each do |h|
85
+ h[:prefix] = h[:prefix].chomp("/")
86
+ h[:path] = h[:path].chomp("/")
87
+ end
88
+ end
89
+
73
90
  def unable_to_determine_version
74
91
  warn red(
75
92
  "Unable to automatically gather info about mounts. This maybe due to vault connectivity or permissions"\
@@ -1,3 +1,3 @@
1
1
  module Sanctum
2
- VERSION = "0.8.5.rc2"
2
+ VERSION = "0.8.5.rc3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanctum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5.rc2
4
+ version: 0.8.5.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corban Raun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-16 00:00:00.000000000 Z
11
+ date: 2019-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vault