dotenv-vault 0.5.0 → 0.6.0

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: f07ef0e741df42c7269f9d949e3b279bc2e244f030b8d2abd3b1cfd49d707d4f
4
- data.tar.gz: c5ebb287fbd0de6d76ba888aea9fab96763329bcb9db19c86444d2b1e9b6d4ed
3
+ metadata.gz: 84e1fef6b134d93f790a2fea8c723ab7a824035ce634abf4b28b59d4926c429b
4
+ data.tar.gz: 0be721f78ed10b1a1fadaf76bb2ba39f37179e7f22dc91005f6ae99ffa0d98b9
5
5
  SHA512:
6
- metadata.gz: 62a9f140d67de2990e183616d6075dbcabddbef118a3a7b91e85e237d6673b02b0136af95661b0f239d62a3cf217956184c8b4532f04b1aeef60e02878860552
7
- data.tar.gz: d904872c3b6c27e5dd71a8ed31703fbbe8765e8cf212ebdadba04932b5addf10672284d0d15a816cacdce1607c45d9048b7bdac1ee8e83a1402d7e03b8f3d26d
6
+ metadata.gz: e269b0db8d1657b41d1913d092ae08e6ce3b717e2fcd3cde12ffe8c49fae30bafb3f1b63c610909f44e659815dae24ba119a5e1a9e4bf85f0c4b49450895f487
7
+ data.tar.gz: 707dac136468912d26dfca5e9b2ac0f3b29488dee6e27f0be9aac43b98d289b2fd4a251909b261fb2ab0d98324dbb585339b2c8a2773df3d922472b46b6bfa08
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dotenv-vault (0.5.0)
4
+ dotenv-vault (0.6.0)
5
5
  dotenv
6
6
  lockbox
7
- dotenv-vault-rails (0.5.0)
7
+ dotenv-vault-rails (0.6.0)
8
8
  dotenv-rails
9
- dotenv-vault (= 0.5.0)
9
+ dotenv-vault (= 0.6.0)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module DotenvVault
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/dotenv-vault.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "uri"
1
2
  require "dotenv"
2
3
  require "lockbox"
3
4
  require "dotenv-vault/version"
@@ -109,15 +110,22 @@ module DotenvVault
109
110
  #
110
111
  # Warn the developer unless formatted correctly
111
112
  raise NotFoundDotenvKey, "NOT_FOUND_DOTENV_KEY: Cannot find ENV['DOTENV_KEY']" unless present?(ENV["DOTENV_KEY"])
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]
113
+
114
+ # Parse DOTENV_KEY. Format is a URI
115
+ uri = URI.parse(ENV["DOTENV_KEY"]) # dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=production
116
+
117
+ # Get decrypt key
118
+ key = uri.password
116
119
  raise InvalidDotenvKey, "INVALID_DOTENV_KEY: Missing key part" unless present?(key)
117
120
 
118
- # Locate .env.vault
119
- vault_path = ".env.vault"
120
- raise NotFoundDotenvVault, "NotFoundDotenvVault: Cannot find .env.vault at ${vaultPath}" unless File.file?(vault_path)
121
+ # Get environment
122
+ params = Hash[URI::decode_www_form(uri.query.to_s)]
123
+ environment = params["environment"]
124
+ raise InvalidDotenvKey, "INVALID_DOTENV_KEY: Missing environment part" unless present?(environment)
125
+
126
+ # Get vault path
127
+ vault_path = uri.path.gsub("/vault/", "") # /vault/.env.vault => .env.vault
128
+ raise NotFoundDotenvVault, "NotFoundDotenvVault: Cannot find .env.vault at #{vaultPath}" unless File.file?(vault_path)
121
129
 
122
130
  # Parse .env.vault
123
131
  parsed = Dotenv.parse(vault_path)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotenv-vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - motdotla