dotenv-vault-rails 0.4.0 → 0.5.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/rails.rb +1 -0
- data/lib/dotenv-vault/version.rb +1 -1
- data/lib/dotenv-vault.rb +14 -10
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca7df12c2227ad12516a6f7372854f0fc7b31db5d34ab6aca23845a316adb06e
|
4
|
+
data.tar.gz: 2602498218cc915c9d39f60d12e2542994e63a592cd0d440ea1f070e01881e59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09f0097149ae52f3a0271384fee27e6843d0fe92989889d3662911ea96d214be3ea53088a096497b6e1f61da4e1977deb30592d034d80fc6dc4b5f9b3ec477fe'
|
7
|
+
data.tar.gz: 6d6baf8ec4d6be0dd8344856a12e02e5a720836bd35a22dee144d68a25a617947fe198d39d36909c590504c784ee5f2f245e4827e1c74b43880870fd9159a383
|
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.5.0)
|
5
5
|
dotenv
|
6
6
|
lockbox
|
7
|
-
dotenv-vault-rails (0.
|
7
|
+
dotenv-vault-rails (0.5.0)
|
8
8
|
dotenv-rails
|
9
|
-
dotenv-vault (= 0.
|
9
|
+
dotenv-vault (= 0.5.0)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
data/lib/dotenv-vault/rails.rb
CHANGED
data/lib/dotenv-vault/version.rb
CHANGED
data/lib/dotenv-vault.rb
CHANGED
@@ -105,9 +105,15 @@ module DotenvVault
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def parse_vault(*filenames)
|
108
|
-
#
|
108
|
+
# DOTENV_KEY=development/key_1234
|
109
|
+
#
|
110
|
+
# Warn the developer unless formatted correctly
|
109
111
|
raise NotFoundDotenvKey, "NOT_FOUND_DOTENV_KEY: Cannot find ENV['DOTENV_KEY']" unless present?(ENV["DOTENV_KEY"])
|
110
|
-
|
112
|
+
split_dotenv_key = ENV["DOTENV_KEY"].split("/")
|
113
|
+
environment = split_dotenv_key[0]
|
114
|
+
raise InvalidDotenvKey, "INVALID_DOTENV_KEY: Missing environment part" unless present?(environment)
|
115
|
+
key = split_dotenv_key[1]
|
116
|
+
raise InvalidDotenvKey, "INVALID_DOTENV_KEY: Missing key part" unless present?(key)
|
111
117
|
|
112
118
|
# Locate .env.vault
|
113
119
|
vault_path = ".env.vault"
|
@@ -117,31 +123,29 @@ module DotenvVault
|
|
117
123
|
parsed = Dotenv.parse(vault_path)
|
118
124
|
|
119
125
|
# Get ciphertext
|
120
|
-
environment_key = "DOTENV_VAULT_#{
|
126
|
+
environment_key = "DOTENV_VAULT_#{environment.upcase}"
|
121
127
|
ciphertext = parsed[environment_key] # DOTENV_VAULT_PRODUCTION
|
122
128
|
raise NotFoundDotenvEnvironment, "NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate #{environment_key} in .env.vault" unless ciphertext
|
123
129
|
|
124
130
|
# Decrypt ciphertext
|
125
|
-
decrypted = decrypt(ciphertext)
|
131
|
+
decrypted = decrypt(ciphertext, key)
|
126
132
|
|
127
133
|
# Parse decrypted .env string
|
128
134
|
Dotenv::Parser.call(decrypted, true)
|
129
135
|
end
|
130
136
|
|
131
137
|
def using_vault?
|
132
|
-
present?(ENV["
|
138
|
+
present?(ENV["DOTENV_KEY"])
|
133
139
|
end
|
134
140
|
|
135
141
|
def present?(str)
|
136
142
|
!(str.nil? || str.empty?)
|
137
143
|
end
|
138
144
|
|
139
|
-
def decrypt(ciphertext)
|
140
|
-
|
141
|
-
|
142
|
-
key = ENV["DOTENV_KEY"][-64..-1] # last 64 characters. allows for passing keys with preface like key_*****
|
145
|
+
def decrypt(ciphertext, key)
|
146
|
+
key = key[-64..-1] # last 64 characters. allows for passing keys with preface like key_*****
|
143
147
|
|
144
|
-
raise InvalidDotenvKey, "INVALID_DOTENV_KEY:
|
148
|
+
raise InvalidDotenvKey, "INVALID_DOTENV_KEY: Key part must be 64 characters long (or more)" unless key.bytesize == 64
|
145
149
|
|
146
150
|
lockbox = Lockbox.new(key: key, encode: true)
|
147
151
|
begin
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- motdotla
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv-rails
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.5.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.5.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: spring
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|