rake_vault 0.1.0.pre.6 → 0.1.0.pre.7

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: 260c539594d7fa4dc45c02a950c7173879bbbb2c2ae90ac54d5caf82340a78bf
4
- data.tar.gz: 5dd668fb52d38a48e16911218a57e36c327671ace3784cc5909f0b3b6a98b8c4
3
+ metadata.gz: a6032db055b2b867a66d1081a178c1d5626f25940fad1a1a94960c215b8f4458
4
+ data.tar.gz: 66c88ba88b13102255484142252b59d486540bfdf40a7be82b35c2f194a7572d
5
5
  SHA512:
6
- metadata.gz: 17d1acd0a89fd8039e078cb46552578a2ed37594089a69d466b0fd46c6be4046018add997e1cb4ddd1424aca3af922ddd5af8bc55c96b4eaef84bae487c325ad
7
- data.tar.gz: 64fc396dd4d2c4edc2a3e853d0cd4c91f25607ebbe8dba708fba5ec89f2251f21c0c19a117b1b4ed4a31ed81ad61bac3c46d46e1eeed8eaefb8b7b522d9d4479
6
+ metadata.gz: a14c7a97440f9d9cdeaa98b79722a60f16bf7ee841090d67ab628a0a2d381b54b381ebad60a603357f2d3e80ca3dbc142038fe3f72a0beeb027fde0902f5b912
7
+ data.tar.gz: fc8a6608c820a956442d6c9279027f50ae595dbd208b8fee570b41a39d886aee56fd2bd195c29b17e92d1b8681bfddecba71b909f16fb30c9e0bc882890fb5c4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_vault (0.1.0.pre.6)
4
+ rake_vault (0.1.0.pre.7)
5
5
  colored2 (~> 3.1)
6
6
  rake_dependencies (~> 3.1)
7
7
  rake_factory (~> 0.23)
@@ -152,4 +152,4 @@ DEPENDENCIES
152
152
  simplecov
153
153
 
154
154
  BUNDLED WITH
155
- 2.3.19
155
+ 2.3.20
@@ -1,13 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rake_factory'
4
+ require_relative '../token_file'
4
5
 
5
6
  module RakeVault
6
7
  module Tasks
7
8
  class AppRoleAuth < RakeFactory::Task
8
9
  default_name :login
9
- action do |_t|
10
- puts 'done'
10
+ default_prerequisites(RakeFactory::DynamicValue.new do |t|
11
+ [t.ensure_task_name]
12
+ end)
13
+ default_description(RakeFactory::DynamicValue.new do |_task|
14
+ 'Login with app role using vault'
15
+ end)
16
+ parameter :address
17
+ parameter :ensure_task_name, default: :'vault:ensure'
18
+ parameter :path, default: 'auth/approle/login'
19
+ parameter :role_id
20
+ parameter :secret_id
21
+
22
+ action do |task|
23
+ role_id = task.role_id ? "role_id=#{task.role_id}" : nil
24
+ secret_id = task.secret_id ? "secret_id=#{task.secret_id}" : nil
25
+
26
+ stdout = StringIO.new
27
+
28
+ RubyVault.configure(stdout: stdout)
29
+ RubyVault.write(
30
+ address: task.address,
31
+ path: task.path,
32
+ data: [role_id, secret_id].compact,
33
+ format: 'json'
34
+ )
35
+ RubyVault.reset!
36
+ RakeVault::TokenFile.write(stdout.string)
11
37
  end
12
38
  end
13
39
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RakeVault
4
+ module TokenFile
5
+ def self.write(json_string)
6
+ json = JSON.parse(json_string)
7
+ token = json['auth']['client_token']
8
+ RakeVault::TokenFile.write_token_to_file(token)
9
+ end
10
+
11
+ def self.write_token_to_file(token)
12
+ file = File.open('~/.vault-token', 'w')
13
+ file.write(token)
14
+ file.close
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RakeVault
4
- VERSION = '0.1.0.pre.6'
4
+ VERSION = '0.1.0.pre.7'
5
5
  end
data/lib/rake_vault.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'rake_vault/tasks'
4
4
  require 'rake_vault/task_sets'
5
5
  require 'rake_vault/version'
6
+ require 'rake_vault/token_file'
6
7
 
7
8
  module RakeVault
8
9
  def self.define_installation_tasks(opts = {})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.6
4
+ version: 0.1.0.pre.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-10 00:00:00.000000000 Z
11
+ date: 2022-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2
@@ -283,6 +283,7 @@ files:
283
283
  - lib/rake_vault/tasks.rb
284
284
  - lib/rake_vault/tasks/app_role_auth.rb
285
285
  - lib/rake_vault/tasks/oidc_auth.rb
286
+ - lib/rake_vault/token_file.rb
286
287
  - lib/rake_vault/version.rb
287
288
  - rake_vault.gemspec
288
289
  homepage: https://github.com/infrablocks/rake_vault