rails_kms_credentials 0.0.1 → 0.0.2

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: d9002ffd4c1c4c037cfefa42fa524a68c695d6fdfa7010a966e5d6a0ed1c0130
4
- data.tar.gz: cd9410a02314fcc000d5e5e44f1947aa8aa0e5a50a8e434fc29775073ced335c
3
+ metadata.gz: c1722bd0996c3a1be492c2bfa72531791a1ac30ed88cb159102a6661e60e3270
4
+ data.tar.gz: 0d9f6bcd5bcddc442e1712b2dfb247c5c71c85fb6636b7777be345e05bb1e2df
5
5
  SHA512:
6
- metadata.gz: 14fc42d0dc79b8da2b0458a8109bf7aa224230e9cb76975fbed7412c32d795c7cfea449a9d75ee62406c9bbbf7995a2776f6bf1281ae3192cee43184b50671ad
7
- data.tar.gz: 4bd8c88b3788508b5ba3e1b3223aceebb862a6595ec76b96b00e70370bb8d2f0e9b43c77b0cd9c2463c4270da17cca0b2bab65e125115c035dc14fd4ff0a4c1c
6
+ metadata.gz: c443e4a5aa075dcf08c675bcfccbc1d49e781b17451370f0bb26f7803dc636df09c4644b4e85a4c6e20675787e97bfa959a19eef045d831f8c2a81f9112663ed
7
+ data.tar.gz: 8db14c441562ee1438df718fd7700f57f86d0967ff364471cfb60e8b770e0a6c47b8d258b24a3aafeeb9a0ab722ab8bca79eb8de0990c2098401f03c7389fbb5
@@ -6,13 +6,37 @@ module RailsKmsCredentials
6
6
  module Client
7
7
  class ManagedIdentity < Base
8
8
  def get_secrets_list(url)
9
- HTTParty.get url
9
+ HTTParty.get(
10
+ url,
11
+ headers: {
12
+ Authorization: "Bearer #{access_token}",
13
+ },
14
+ )
10
15
  end
11
16
 
12
17
  def get_secret(url)
13
- HTTParty.get url
18
+ HTTParty.get(
19
+ url,
20
+ headers: {
21
+ Authorization: "Bearer #{access_token}",
22
+ },
23
+ )
14
24
  end
15
25
 
26
+ private
27
+
28
+ def access_token
29
+ return @access_token if instance_variable_defined?(:@access_token)
30
+ @_access_token_response = HTTParty.get(
31
+ 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fvault.azure.net',
32
+ {
33
+ headers: { Metadata: 'true' },
34
+ }
35
+ )
36
+ raise 'KmsCredentials AzureKeyVault ClientCredentials unable to get access token' unless @_access_token_response.ok?
37
+ @access_token = @_access_token_response['access_token']
38
+ end
39
+
16
40
  end
17
41
 
18
42
  add(:managed_identity, ManagedIdentity)
@@ -5,7 +5,7 @@ module RailsKmsCredentials
5
5
  module Version
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 1
8
+ PATCH = 2
9
9
 
10
10
  end
11
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_kms_credentials
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Yelverton