awskeyring 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e7e03d81e3086c6acea16f7eb514d1d52066bb5
4
- data.tar.gz: 7af0c1e501fd4f11e331f6abec07329c997e0a47
3
+ metadata.gz: c334764f64951c2cdc1956a0289601b6c088bd5c
4
+ data.tar.gz: 2dd4c1112a6ee8eb15821d93e9ff352ce2267fac
5
5
  SHA512:
6
- metadata.gz: d067652302c5c5e43e4975c392f880d373f61ca989c644a7c2fd473bd42c0723cbfc2cd041cc12c73a3add31752155ed8dd8bf15f71beb429e1b10f84edd81a4
7
- data.tar.gz: 8f3434517adcbdf5185c315b1f33ae250d08dd56cb74e18c7d28397a3dd828fb6ce4209c28d9d6104f0085f34bb29c4f80c47e70d358e9e4cf54857f67bfb80a
6
+ metadata.gz: a4faa576d8f631d0b3ffb687760de1a813e0f4fd2e92ea2dbf463e5c63bd0b25b6eb61381d0a96d2943bf0d779e15de2c234571d8a7a0e11d52a146b6127959b
7
+ data.tar.gz: b2cc0d573f5acda892c2d84f7d6e51254122498da548ef2d89567f820f93b55bd82fc986354fd4eee45e9512238d46896e6f010498be21c7f01643c9eae00620
data/.rubocop.yml CHANGED
@@ -4,11 +4,14 @@ Metrics/LineLength:
4
4
  Metrics/MethodLength:
5
5
  Max: 16
6
6
 
7
+ Metrics/BlockLength:
8
+ Exclude:
9
+ - spec/*
10
+
7
11
  Naming/FileName:
8
12
  Exclude:
9
13
  - Gemfile
10
14
  - Rakefile
11
- - aws-keychain-util.gemspec
12
15
 
13
16
  AllCops:
14
17
  Exclude:
data/.travis.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  language: ruby
2
2
  os: osx
3
3
  rvm:
4
- - 2.3.3
4
+ - 2.3.3
5
5
  before_install: gem install bundler
6
+ notifications:
7
+ slack:
8
+ secure: okKLlQ93ogj8ut18MZazQD63XTIzCpTfneYQMlKPaLU5HnooAkUFmEpSN8igTJD0GuEQ7Jf8+BkFlhECWl1FwtzIW6z/yMadiiLwY6qA/O1ZVVYZmkS4kpcKtCMrvO0Hf3iPLXpJX0sQGfGsMsho6NZuNs0dzlrr4+HX/cEGmDXBocDDxdv2d25HzHtqt4l+4axeJ+PJdHDmYlDzhtMAXhkGoPfzws7MPvkVcqY0eZRW2WqccO52zlQrBNcphp7BI8mLTW/BwkEY9YndJf2xoBaoEOuaIJbGgHbmskGMRui3vZnd08/fiWkNsCI/EhB5BDJ41bwobsHEtuqu+Qx92kI+hzjtU4D16k1v/6HDm61T6gh6BTp0QEXJeOkiecjVGyzrMlBf5BEyIB7JfLvGPa7RUbvvvUxFGcEtnSbUZ49cXAG7cKiiSgcNOocCrMNIRAe864Tm606Mud1RbOv8tEiS9BJ96ktOpOfvrYPyYMRFTte2gRLwNDwcpXIWTI39CXD2EBxSfRK/OqmggLYMG5AKhxyS/Vl7E2p9gii6syB0LnpFBIZ6t+OSve7fZtCU/wruC5IrI/vHtWfApvADYKsXG6FEYJoJ1LsCDjIRlrkwV1dEVsp/HSSO6zRh9KhJ3b7yzL97Dyi6dCi+nM7aKGrox/8kvcn9alrdRt8sz3c=
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # Change Log
2
+
3
+ ## [0.0.3](https://github.com/vibrato/awskeyring/tree/0.0.3) (2018-01-29)
4
+ [Full Changelog](https://github.com/vibrato/awskeyring/compare/v0.0.2...0.0.3)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Remove Token feature [\#5](https://github.com/vibrato/awskeyring/issues/5)
9
+ - Implement exec command [\#2](https://github.com/vibrato/awskeyring/issues/2)
10
+ - Add Remove token feature [\#6](https://github.com/vibrato/awskeyring/pull/6) ([tristanmorgan](https://github.com/tristanmorgan))
11
+ - Implement exec feature. [\#3](https://github.com/vibrato/awskeyring/pull/3) ([tristanmorgan](https://github.com/tristanmorgan))
12
+
13
+ ## [v0.0.2](https://github.com/vibrato/awskeyring/tree/v0.0.2) (2018-01-18)
14
+ [Full Changelog](https://github.com/vibrato/awskeyring/compare/v0.0.1...v0.0.2)
15
+
16
+ **Merged pull requests:**
17
+
18
+ - Sledgehammer disable of rubocop metrics. [\#1](https://github.com/vibrato/awskeyring/pull/1) ([tristanmorgan](https://github.com/tristanmorgan))
19
+
20
+ ## [v0.0.1](https://github.com/vibrato/awskeyring/tree/v0.0.1) (2017-12-25)
21
+
22
+
23
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/README.md CHANGED
@@ -27,18 +27,20 @@ Install it with:
27
27
  The CLI is using [Thor](http://whatisthor.com) with help provided interactively.
28
28
 
29
29
  Commands:
30
- awskeyring --version, -v # Prints the version
31
- awskeyring add ACCOUNT # Adds an ACCOUNT to the keyring
32
- awskeyring add-role ROLE # Adds a ROLE to the keyring
33
- awskeyring console ACCOUNT # Open the AWS Console for the ACCOUNT
34
- awskeyring env ACCOUNT # Outputs bourne shell environment exports for an ACCOUNT
35
- awskeyring help [COMMAND] # Describe available commands or one specific command
36
- awskeyring initialise # Initialises a new KEYCHAIN
37
- awskeyring list # Prints a list of accounts in the keyring
38
- awskeyring list-role # Prints a list of roles in the keyring
39
- awskeyring remove ACCOUNT # Removes an ACCOUNT from the keyring
40
- awskeyring remove-role ROLE # Removes a ROLE from the keyring
41
- awskeyring token ACCOUNT [ROLE] [MFA] # Create an STS Token from a ROLE or an MFA code
30
+ awskeyring --version, -v # Prints the version
31
+ awskeyring add ACCOUNT # Adds an ACCOUNT to the keyring
32
+ awskeyring add-role ROLE # Adds a ROLE to the keyring
33
+ awskeyring console ACCOUNT # Open the AWS Console for the ACCOUNT
34
+ awskeyring env ACCOUNT # Outputs bourne shell environment exports for an ACCOUNT
35
+ awskeyring exec ACCOUNT command... # Execute a COMMAND with the environment set for an ACCOUNT
36
+ awskeyring help [COMMAND] # Describe available commands or one specific command
37
+ awskeyring initialise # Initialises a new KEYCHAIN
38
+ awskeyring list # Prints a list of accounts in the keyring
39
+ awskeyring list-role # Prints a list of roles in the keyring
40
+ awskeyring remove ACCOUNT # Removes an ACCOUNT from the keyring
41
+ awskeyring remove-role ROLE # Removes a ROLE from the keyring
42
+ awskeyring remove-token ACCOUNT # Removes a token for ACCOUNT from the keyring
43
+ awskeyring token ACCOUNT [ROLE] [MFA] # Create an STS Token from a ROLE or an MFA code
42
44
 
43
45
  and autocomplete that can be installed with:
44
46
 
data/Rakefile CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
  require 'rubocop/rake_task'
4
+ require 'github_changelog_generator/task'
5
+
6
+ GitHubChangelogGenerator::RakeTask.new :changelog
4
7
 
5
8
  RuboCop::RakeTask.new do |rubocop|
6
9
  rubocop.options = ['-D']
data/awskeyring.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency('thor')
25
25
 
26
26
  spec.add_development_dependency 'bundler'
27
+ spec.add_development_dependency 'github_changelog_generator'
27
28
  spec.add_development_dependency 'rake'
28
29
  spec.add_development_dependency 'rspec'
29
30
  spec.add_development_dependency 'rubocop'
@@ -1,3 +1,3 @@
1
1
  module Awskeyring
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
@@ -11,10 +11,12 @@ require 'awskeyring/version'
11
11
  # AWS Key-ring command line interface.
12
12
  class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
13
13
  map %w[--version -v] => :__version
14
+ map ['init'] => :initialise
14
15
  map ['ls'] => :list
15
16
  map ['lsr'] => :list_role
16
17
  map ['rm'] => :remove
17
18
  map ['rmr'] => :remove_role
19
+ map ['rmt'] => :remove_token
18
20
 
19
21
  desc '--version, -v', 'Prints the version'
20
22
  def __version
@@ -66,6 +68,20 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
66
68
  )
67
69
  end
68
70
 
71
+ desc 'exec ACCOUNT command...', 'Execute a COMMAND with the environment set for an ACCOUNT'
72
+ def exec(account, *command)
73
+ cred, temp_cred = get_valid_item_pair(account: account)
74
+ token = temp_cred.password unless temp_cred.nil?
75
+ env_vars = env_vars(
76
+ account: cred.attributes[:label],
77
+ key: cred.attributes[:account],
78
+ secret: cred.password,
79
+ token: token
80
+ )
81
+ pid = spawn(env_vars, command.join(' '))
82
+ Process.wait pid
83
+ end
84
+
69
85
  desc 'add ACCOUNT', 'Adds an ACCOUNT to the keyring'
70
86
  method_option :key, type: :string, aliases: '-k', desc: 'AWS account key id.'
71
87
  method_option :secret, type: :string, aliases: '-s', desc: 'AWS account secret.'
@@ -106,6 +122,14 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
106
122
  Awskeyring.delete_pair(cred, temp_cred, "# Removing account #{account}")
107
123
  end
108
124
 
125
+ desc 'remove-token ACCOUNT', 'Removes a token for ACCOUNT from the keyring'
126
+ def remove_token(account = nil)
127
+ account = ask_missing(existing: account, message: 'account name')
128
+ session_key, session_token = Awskeyring.get_pair(account)
129
+ session_key, session_token = Awskeyring.delete_expired(session_key, session_token) if session_key
130
+ Awskeyring.delete_pair(session_key, session_token, "# Removing token for account #{account}") if session_key
131
+ end
132
+
109
133
  map 'remove-role' => :remove_role
110
134
  desc 'remove-role ROLE', 'Removes a ROLE from the keyring'
111
135
  def remove_role(role = nil)
@@ -236,7 +260,8 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
236
260
  def awskeyring(curr, prev)
237
261
  comp_line = ENV['COMP_LINE']
238
262
  unless comp_line
239
- warn "enable autocomplete with 'complete -C /path-to-command/awskeyring awskeyring'"
263
+ exec_name = File.basename($PROGRAM_NAME)
264
+ warn "enable autocomplete with 'complete -C /path-to-command/#{exec_name} #{exec_name}'"
240
265
  exit 1
241
266
  end
242
267
  comp_len = comp_line.split.length
@@ -283,19 +308,27 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
283
308
  [item, nil]
284
309
  end
285
310
 
286
- def put_env_string(account:, key:, secret:, token:)
287
- puts "export AWS_ACCOUNT_NAME=\"#{account}\""
288
- puts "export AWS_ACCESS_KEY_ID=\"#{key}\""
289
- puts "export AWS_ACCESS_KEY=\"#{key}\""
290
- puts "export AWS_SECRET_ACCESS_KEY=\"#{secret}\""
291
- puts "export AWS_SECRET_KEY=\"#{secret}\""
311
+ def env_vars(account:, key:, secret:, token:)
312
+ env_var = {}
313
+ env_var['AWS_DEFAULT_REGION'] = 'us-east-1' unless ENV['AWS_DEFAULT_REGION']
314
+ env_var['AWS_ACCOUNT_NAME'] = account
315
+ env_var['AWS_ACCESS_KEY_ID'] = key
316
+ env_var['AWS_ACCESS_KEY'] = key
317
+ env_var['AWS_SECRET_ACCESS_KEY'] = secret
318
+ env_var['AWS_SECRET_KEY'] = secret
292
319
  if token
293
- puts "export AWS_SECURITY_TOKEN=\"#{token}\""
294
- puts "export AWS_SESSION_TOKEN=\"#{token}\""
295
- else
296
- puts 'unset AWS_SECURITY_TOKEN'
297
- puts 'unset AWS_SESSION_TOKEN'
320
+ env_var['AWS_SECURITY_TOKEN'] = token
321
+ env_var['AWS_SESSION_TOKEN'] = token
298
322
  end
323
+ env_var
324
+ end
325
+
326
+ def put_env_string(account:, key:, secret:, token:)
327
+ env_var = env_vars(account: account, key: key, secret: secret, token: token)
328
+ env_var.each { |var, value| puts "export #{var}=\"#{value}\"" }
329
+
330
+ puts 'unset AWS_SECURITY_TOKEN' unless token
331
+ puts 'unset AWS_SESSION_TOKEN' unless token
299
332
  end
300
333
 
301
334
  def ask_missing(existing:, message:, secure: false, optional: false)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awskeyring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tristan Morgan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-19 00:00:00.000000000 Z
11
+ date: 2018-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-iam
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: github_changelog_generator
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rake
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -134,6 +148,7 @@ files:
134
148
  - ".rspec"
135
149
  - ".rubocop.yml"
136
150
  - ".travis.yml"
151
+ - CHANGELOG.md
137
152
  - CODE_OF_CONDUCT.md
138
153
  - Gemfile
139
154
  - LICENSE.txt