dotenv-vault-rails 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/dotenv-vault/version.rb +1 -1
- data/lib/dotenv-vault.rb +24 -7
- 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: 4fd6eab8f7ad51c5b1f2b33187eddbcfe000b95e74538fce3d08850990ec5f76
|
4
|
+
data.tar.gz: 20d9bf1e87a3e2c3cd863ad47ecfd8ed7db6608bccc78828da8b38a23f901f0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f41e45e09a9f1c97bfc4fa64b0e4322bbd917e30e827b886f80d23d28287aaa894957a27a17b28d119fcf59c741a60b5794fb3dc67dc42c8c77af5b94a4ae43
|
7
|
+
data.tar.gz: 95f221dfd6927d2a04d359079a51a6493d0fc05ba6a79324c1cf5a65e2c2aa31097a1cb1590ec2639623443b8617dc6600592c21db50214dc8f1af9eb57d687c
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dotenv-vault (0.
|
4
|
+
dotenv-vault (0.7.0)
|
5
5
|
dotenv
|
6
6
|
lockbox
|
7
|
-
dotenv-vault-rails (0.
|
7
|
+
dotenv-vault-rails (0.7.0)
|
8
8
|
dotenv-rails
|
9
|
-
dotenv-vault (= 0.
|
9
|
+
dotenv-vault (= 0.7.0)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
data/lib/dotenv-vault/version.rb
CHANGED
data/lib/dotenv-vault.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
require "uri"
|
1
2
|
require "dotenv"
|
2
3
|
require "lockbox"
|
3
4
|
require "dotenv-vault/version"
|
5
|
+
require "logger"
|
4
6
|
|
5
7
|
module DotenvVault
|
6
8
|
class NotFoundDotenvKey < ArgumentError; end
|
@@ -13,6 +15,10 @@ module DotenvVault
|
|
13
15
|
|
14
16
|
class << self
|
15
17
|
attr_accessor :instrumenter
|
18
|
+
|
19
|
+
def logger
|
20
|
+
@logger ||= Logger.new(STDOUT)
|
21
|
+
end
|
16
22
|
end
|
17
23
|
|
18
24
|
module_function
|
@@ -84,6 +90,8 @@ module DotenvVault
|
|
84
90
|
#
|
85
91
|
# Decrypts and loads to ENV
|
86
92
|
def load_vault(*filenames)
|
93
|
+
DotenvVault.logger.info("[dotenv-vault] Loading .env.vault") if DotenvVault.logger
|
94
|
+
|
87
95
|
parsed = parse_vault(*filenames)
|
88
96
|
|
89
97
|
# Set ENV
|
@@ -96,6 +104,8 @@ module DotenvVault
|
|
96
104
|
#
|
97
105
|
# Decrypts and overloads to ENV
|
98
106
|
def overload_vault(*filenames)
|
107
|
+
DotenvVault.logger.info("[dotenv-vault] Overloading .env.vault") if DotenvVault.logger
|
108
|
+
|
99
109
|
parsed = parse_vault(*filenames)
|
100
110
|
|
101
111
|
# Set ENV
|
@@ -109,15 +119,22 @@ module DotenvVault
|
|
109
119
|
#
|
110
120
|
# Warn the developer unless formatted correctly
|
111
121
|
raise NotFoundDotenvKey, "NOT_FOUND_DOTENV_KEY: Cannot find ENV['DOTENV_KEY']" unless present?(ENV["DOTENV_KEY"])
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
122
|
+
|
123
|
+
# Parse DOTENV_KEY. Format is a URI
|
124
|
+
uri = URI.parse(ENV["DOTENV_KEY"]) # dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=production
|
125
|
+
|
126
|
+
# Get decrypt key
|
127
|
+
key = uri.password
|
116
128
|
raise InvalidDotenvKey, "INVALID_DOTENV_KEY: Missing key part" unless present?(key)
|
117
129
|
|
118
|
-
#
|
119
|
-
|
120
|
-
|
130
|
+
# Get environment
|
131
|
+
params = Hash[URI::decode_www_form(uri.query.to_s)]
|
132
|
+
environment = params["environment"]
|
133
|
+
raise InvalidDotenvKey, "INVALID_DOTENV_KEY: Missing environment part" unless present?(environment)
|
134
|
+
|
135
|
+
# Get vault path
|
136
|
+
vault_path = uri.path.gsub("/vault/", "") # /vault/.env.vault => .env.vault
|
137
|
+
raise NotFoundDotenvVault, "NotFoundDotenvVault: Cannot find .env.vault at #{vaultPath}" unless File.file?(vault_path)
|
121
138
|
|
122
139
|
# Parse .env.vault
|
123
140
|
parsed = Dotenv.parse(vault_path)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotenv-vault-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- motdotla
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.7.0
|
34
34
|
type: :runtime
|
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: 0.
|
40
|
+
version: 0.7.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: spring
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|