awskeyring 1.8.0 → 1.8.5

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: b48c06baceecbcec6e2b949d0985d8e67b788988385545a0c5c93ef1b355728d
4
- data.tar.gz: 5409309869822c30497465a753a40e1717a3cee31f040ad80e287c71bbc2ae50
3
+ metadata.gz: df8b15491f307691db7f25727bdc12f5a90ba71b816e6b14b14a71bdbd53c594
4
+ data.tar.gz: af3cc61ea5c8c44025254b5fb9a90a087e67a2c556f7391006acc188ab5be214
5
5
  SHA512:
6
- metadata.gz: 202db6a54856b8365246994f5a814b657d4b6f4912d170c80cf979d2bd4818d4a58150daf737a2f3085ebb8b4ad39788e92de809b6fbe0dea59315d4abed1717
7
- data.tar.gz: 70e3cb77196023d67bd60e5b4b9afc6ddfdbac4b2f5a89610ed5f068e97e604e5884a29c30ae0ec7be3c73f3ad77e613e7f9e957d9ef1e84393a30e6fe55080b
6
+ metadata.gz: c20ade29e6499e0fa836cb7532dd1dd8776659ed7c3e69cc905c6ea34ae5a46b3af24320a94781996af7cdbb0cc4e69fabe86259d7aaa99048b577c5a9a09208
7
+ data.tar.gz: 547a0ad97e0e38b7b6e61d7b8275ab75c18a114d83a540de293c410cd4835f4a429bf829863e62fce4c8350ece488d0d4d4a0571c17b9e1a0b97b4416eaa51e2
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017-2020 Tristan Morgan
3
+ Copyright (c) 2017-2021 Tristan Morgan
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![Awskeyring](https://raw.githubusercontent.com/servian/awskeyring/main/awskeyring-144.png)
4
4
 
5
- * [![Build Status](https://travis-ci.org/servian/awskeyring.svg?branch=main)](https://travis-ci.org/servian/awskeyring)
5
+ * [![Build Status](https://travis-ci.com/servian/awskeyring.svg?branch=main)](https://travis-ci.com/servian/awskeyring)
6
6
  * [![Gem Version](https://badge.fury.io/rb/awskeyring.svg)](https://badge.fury.io/rb/awskeyring)
7
7
  * [![license MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
8
8
  * [![All Downloads](https://ruby-gem-downloads-badge.herokuapp.com/awskeyring?type=total)](https://rubygems.org/gems/awskeyring)
@@ -61,25 +61,25 @@ more details on this config option.
61
61
 
62
62
  The CLI is using [Thor](http://whatisthor.com) with help provided interactively.
63
63
 
64
- Commands:
65
- awskeyring --version, -v # Prints the version
66
- awskeyring add ACCOUNT # Adds an ACCOUNT to the keyring
67
- awskeyring add-role ROLE # Adds a ROLE to the keyring
68
- awskeyring console ACCOUNT # Open the AWS Console for the ACCOUNT
69
- awskeyring env ACCOUNT # Outputs bourne shell environment exports for an ACCOUNT
70
- awskeyring exec ACCOUNT command... # Execute a COMMAND with the environment set for an ACCOUNT
71
- awskeyring help [COMMAND] # Describe available commands or one specific command
72
- awskeyring import ACCOUNT # Import an ACCOUNT to the keyring from ~/.aws/credentials
73
- awskeyring initialise # Initialises a new KEYCHAIN
74
- awskeyring json ACCOUNT # Outputs AWS CLI compatible JSON for an ACCOUNT
75
- awskeyring list # Prints a list of accounts in the keyring
76
- awskeyring list-role # Prints a list of roles in the keyring
77
- awskeyring remove ACCOUNT # Removes an ACCOUNT from the keyring
78
- awskeyring remove-role ROLE # Removes a ROLE from the keyring
79
- awskeyring remove-token ACCOUNT # Removes a token for ACCOUNT from the keyring
80
- awskeyring rotate ACCOUNT # Rotate access keys for an ACCOUNT
81
- awskeyring token ACCOUNT [ROLE] [MFA] # Create an STS Token from a ROLE or an MFA code
82
- awskeyring update ACCOUNT # Updates an ACCOUNT in the keyring
64
+ Awskeyring commands:
65
+ awskeyring --version, -v # Prints the version
66
+ awskeyring add ACCOUNT # Adds an ACCOUNT to the keyring
67
+ awskeyring add-role ROLE # Adds a ROLE to the keyring
68
+ awskeyring console ACCOUNT # Open the AWS Console for the ACCOUNT
69
+ awskeyring env ACCOUNT # Outputs bourne shell environment exports for an ACCOUNT
70
+ awskeyring exec ACCOUNT command... # Execute a COMMAND with the environment set for an ACCOUNT
71
+ awskeyring help [COMMAND] # Describe available commands or one specific command
72
+ awskeyring import ACCOUNT # Import an ACCOUNT to the keyring from ~/.aws/credentials
73
+ awskeyring initialise # Initialises a new KEYCHAIN
74
+ awskeyring json ACCOUNT # Outputs AWS CLI compatible JSON for an ACCOUNT
75
+ awskeyring list # Prints a list of accounts in the keyring
76
+ awskeyring list-role # Prints a list of roles in the keyring
77
+ awskeyring remove ACCOUNT # Removes an ACCOUNT from the keyring
78
+ awskeyring remove-role ROLE # Removes a ROLE from the keyring
79
+ awskeyring remove-token ACCOUNT # Removes a token for ACCOUNT from the keyring
80
+ awskeyring rotate ACCOUNT # Rotate access keys for an ACCOUNT
81
+ awskeyring token ACCOUNT [ROLE] [CODE] # Create an STS Token from a ROLE or an mfa CODE
82
+ awskeyring update ACCOUNT # Updates an ACCOUNT in the keyring
83
83
 
84
84
  and autocomplete that can be installed with:
85
85
 
@@ -91,7 +91,7 @@ There are also short forms of most commands if you prefer:
91
91
 
92
92
  To set your environment easily the following bash function helps:
93
93
 
94
- awsenv() { eval "$(awskeyring env $@)"; }
94
+ awsenv() { eval "$(awskeyring env ${@:-$AWS_ACCOUNT_NAME})"; }
95
95
 
96
96
  ## Development
97
97
 
data/Rakefile CHANGED
@@ -55,8 +55,9 @@ task :ronn do
55
55
  end
56
56
 
57
57
  YARD::Rake::YardocTask.new do |t|
58
- t.options = ['--fail-on-warning', '--no-progress']
58
+ t.options = ['--fail-on-warning', '--no-progress', '--files', '*.md']
59
59
  t.stats_options = ['--list-undoc']
60
60
  end
61
61
 
62
+ desc 'Run Linting, Tests and Documetation tasks'
62
63
  task default: %i[filemode rubocop spec ronn yard]
data/awskeyring.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.homepage = Awskeyring::HOMEPAGE
16
16
  spec.licenses = ['MIT']
17
17
 
18
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/|^\..*|^.*\.png}) }
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/|^\..*|C.*\.md|.*\.ronn|.*\.png}) }
19
19
  spec.bindir = 'exe'
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
data/i18n/en.yml CHANGED
@@ -1,41 +1,24 @@
1
1
  ---
2
2
  en:
3
- __version:
4
- desc: Prints the version
5
- add:
6
- desc: Adds an ACCOUNT to the keyring
7
- add_role:
8
- desc: Adds a ROLE to the keyring
9
- awskeyring:
10
- desc: Autocompletion for bourne shells
11
- console:
12
- desc: Open the AWS Console for the ACCOUNT
13
- env:
14
- desc: Outputs bourne shell environment exports for an ACCOUNT
15
- exec:
16
- desc: Execute a COMMAND with the environment set for an ACCOUNT
17
- import:
18
- desc: Import an ACCOUNT to the keyring from ~/.aws/credentials
19
- initialise:
20
- desc: Initialises a new KEYCHAIN
21
- json:
22
- desc: Outputs AWS CLI compatible JSON for an ACCOUNT
23
- list:
24
- desc: Prints a list of accounts in the keyring
25
- list_role:
26
- desc: Prints a list of roles in the keyring
27
- remove:
28
- desc: Removes an ACCOUNT from the keyring
29
- remove_role:
30
- desc: Removes a ROLE from the keyring
31
- remove_token:
32
- desc: Removes a token for ACCOUNT from the keyring
33
- rotate:
34
- desc: Rotate access keys for an ACCOUNT
35
- token:
36
- desc: Create an STS Token from a ROLE or an MFA code
37
- update:
38
- desc: Updates an ACCOUNT in the keyring
3
+ __version_desc: Prints the version
4
+ add_desc: Adds an ACCOUNT to the keyring
5
+ add_role_desc: Adds a ROLE to the keyring
6
+ awskeyring_desc: Autocompletion for bourne shells
7
+ console_desc: Open the AWS Console for the ACCOUNT
8
+ default_desc: Run default help or initialise if needed.
9
+ env_desc: Outputs bourne shell environment exports for an ACCOUNT
10
+ exec_desc: Execute a COMMAND with the environment set for an ACCOUNT
11
+ import_desc: Import an ACCOUNT to the keyring from ~/.aws/credentials
12
+ initialise_desc: Initialises a new KEYCHAIN
13
+ json_desc: Outputs AWS CLI compatible JSON for an ACCOUNT
14
+ list_desc: Prints a list of accounts in the keyring
15
+ list_role_desc: Prints a list of roles in the keyring
16
+ remove_desc: Removes an ACCOUNT from the keyring
17
+ remove_role_desc: Removes a ROLE from the keyring
18
+ remove_token_desc: Removes a token for ACCOUNT from the keyring
19
+ rotate_desc: Rotate access keys for an ACCOUNT
20
+ token_desc: Create an STS Token from a ROLE or an mfa CODE
21
+ update_desc: Updates an ACCOUNT in the keyring
39
22
  method_option:
40
23
  arn: 'AWS role arn.'
41
24
  code: 'Virtual mfa CODE.'
@@ -50,7 +33,6 @@ en:
50
33
  noremote: 'Do not validate with remote api.'
51
34
  path: 'The service PATH to open.'
52
35
  browser: 'Specify an alternative browser.'
53
- role: 'The ROLE to assume.'
54
36
  secret: 'AWS account secret.'
55
37
  unset: 'Unset environment variables.'
56
38
  message:
@@ -145,7 +145,7 @@ module Awskeyring
145
145
  # @param [String] key The aws_access_key_id
146
146
  # @param [String] secret The aws_secret_access_key
147
147
  # @param [String] token The aws_session_token
148
- def self.verify_cred(key:, secret:, token:)
148
+ def self.verify_cred(key:, secret:, token: nil)
149
149
  begin
150
150
  ENV['AWS_DEFAULT_REGION'] = 'us-east-1' unless region
151
151
  sts = Aws::STS::Client.new(access_key_id: key, secret_access_key: secret, session_token: token)
@@ -6,7 +6,7 @@ require 'json'
6
6
  # Version const and query of latest.
7
7
  module Awskeyring
8
8
  # The Gem's version number
9
- VERSION = '1.8.0'
9
+ VERSION = '1.8.5'
10
10
  # The Gem's homepage
11
11
  HOMEPAGE = 'https://github.com/servian/awskeyring'
12
12
 
@@ -11,29 +11,37 @@ require 'awskeyring/version'
11
11
 
12
12
  # AWSkeyring command line interface.
13
13
  class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
14
+ package_name 'Awskeyring'
14
15
  I18n.load_path = Dir.glob(File.join(File.realpath(__dir__), '..', 'i18n', '*.{yml,yaml}'))
15
16
  I18n.backend.load_translations
16
17
 
17
18
  map %w[--version -v] => :__version
18
19
  map %w[--help -h] => :help
19
- map ['init'] => :initialise
20
- map ['adr'] => :add_role
21
- map ['con'] => :console
22
- map ['ls'] => :list
23
- map ['lsr'] => :list_role
24
- map ['rm'] => :remove
25
- map ['rmr'] => :remove_role
26
- map ['rmt'] => :remove_token
27
- map ['rot'] => :rotate
28
- map ['tok'] => :token
29
- map ['up'] => :update
20
+ map 'adr' => :add_role
21
+ map 'assume-role' => :token
22
+ map 'ls' => :list
23
+ map 'lsr' => :list_role
24
+ map 'rm' => :remove
25
+ map 'rmr' => :remove_role
26
+ map 'rmt' => :remove_token
27
+ default_command :default
30
28
 
31
29
  # default to returning an error on failure.
32
30
  def self.exit_on_failure?
33
31
  true
34
32
  end
35
33
 
36
- desc '--version, -v', I18n.t('__version.desc')
34
+ desc 'default', I18n.t('default_desc'), hide: true
35
+ # default command to run
36
+ def default
37
+ if Awskeyring.prefs.empty?
38
+ invoke :initialise
39
+ else
40
+ invoke :help
41
+ end
42
+ end
43
+
44
+ desc '--version, -v', I18n.t('__version_desc')
37
45
  method_option 'no-remote', type: :boolean, aliases: '-r', desc: I18n.t('method_option.noremote'), default: false
38
46
  # print the version number
39
47
  def __version
@@ -44,7 +52,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
44
52
  puts "Homepage #{Awskeyring::HOMEPAGE}"
45
53
  end
46
54
 
47
- desc 'initialise', I18n.t('initialise.desc')
55
+ desc 'initialise', I18n.t('initialise_desc')
48
56
  method_option :keychain, type: :string, aliases: '-n', desc: I18n.t('method_option.keychain')
49
57
  # initialise the keychain
50
58
  def initialise
@@ -69,7 +77,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
69
77
  puts I18n.t('message.addkeychain', keychain: keychain, exec_name: exec_name)
70
78
  end
71
79
 
72
- desc 'list', I18n.t('list.desc')
80
+ desc 'list', I18n.t('list_desc')
73
81
  # list the accounts
74
82
  def list
75
83
  if Awskeyring.list_account_names.empty?
@@ -79,9 +87,8 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
79
87
  puts Awskeyring.list_account_names.join("\n")
80
88
  end
81
89
 
82
- map 'list-role' => :list_role
83
- desc 'list-role', I18n.t('list_role.desc')
84
- method_option 'detail', type: :boolean, aliases: '-d', desc: I18n.t('method_option.detail'), default: false
90
+ desc 'list-role', I18n.t('list_role_desc')
91
+ method_option :detail, type: :boolean, aliases: '-d', desc: I18n.t('method_option.detail'), default: false
85
92
  # List roles
86
93
  def list_role
87
94
  if Awskeyring.list_role_names.empty?
@@ -95,9 +102,9 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
95
102
  end
96
103
  end
97
104
 
98
- desc 'env ACCOUNT', I18n.t('env.desc')
105
+ desc 'env ACCOUNT', I18n.t('env_desc')
99
106
  method_option 'no-token', type: :boolean, aliases: '-n', desc: I18n.t('method_option.notoken'), default: false
100
- method_option 'unset', type: :boolean, aliases: '-u', desc: I18n.t('method_option.unset'), default: false
107
+ method_option :unset, type: :boolean, aliases: '-u', desc: I18n.t('method_option.unset'), default: false
101
108
  # Print Env vars
102
109
  def env(account = nil)
103
110
  if options[:unset]
@@ -113,7 +120,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
113
120
  end
114
121
  end
115
122
 
116
- desc 'json ACCOUNT', I18n.t('json.desc')
123
+ desc 'json ACCOUNT', I18n.t('json_desc')
117
124
  method_option 'no-token', type: :boolean, aliases: '-n', desc: I18n.t('method_option.notoken'), default: false
118
125
  # Print JSON for use with credential_process
119
126
  def json(account)
@@ -130,7 +137,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
130
137
  )
131
138
  end
132
139
 
133
- desc 'import ACCOUNT', I18n.t('import.desc')
140
+ desc 'import ACCOUNT', I18n.t('import_desc')
134
141
  method_option 'no-remote', type: :boolean, aliases: '-r', desc: I18n.t('method_option.noremote'), default: false
135
142
  # Import an Account
136
143
  def import(account = nil) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
@@ -166,7 +173,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
166
173
  end
167
174
  end
168
175
 
169
- desc 'exec ACCOUNT command...', I18n.t('exec.desc')
176
+ desc 'exec ACCOUNT command...', I18n.t('exec_desc')
170
177
  method_option 'no-token', type: :boolean, aliases: '-n', desc: I18n.t('method_option.notoken'), default: false
171
178
  method_option 'no-bundle', type: :boolean, aliases: '-b', desc: I18n.t('method_option.nobundle'), default: false
172
179
  # execute an external command with env set
@@ -188,7 +195,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
188
195
  end
189
196
  end
190
197
 
191
- desc 'add ACCOUNT', I18n.t('add.desc')
198
+ desc 'add ACCOUNT', I18n.t('add_desc')
192
199
  method_option :key, type: :string, aliases: '-k', desc: I18n.t('method_option.key')
193
200
  method_option :secret, type: :string, aliases: '-s', desc: I18n.t('method_option.secret')
194
201
  method_option :mfa, type: :string, aliases: '-m', desc: I18n.t('method_option.mfa')
@@ -209,7 +216,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
209
216
  existing: options[:mfa], message: I18n.t('message.mfa'),
210
217
  flags: 'optional', validator: Awskeyring::Validate.method(:mfa_arn)
211
218
  )
212
- Awskeyring::Awsapi.verify_cred(key: key, secret: secret, token: nil) unless options['no-remote']
219
+ Awskeyring::Awsapi.verify_cred(key: key, secret: secret) unless options['no-remote']
213
220
  Awskeyring.add_account(
214
221
  account: account,
215
222
  key: key,
@@ -219,7 +226,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
219
226
  puts I18n.t('message.addaccount', account: account)
220
227
  end
221
228
 
222
- desc 'update ACCOUNT', I18n.t('update.desc')
229
+ desc 'update ACCOUNT', I18n.t('update_desc')
223
230
  method_option :key, type: :string, aliases: '-k', desc: I18n.t('method_option.key')
224
231
  method_option :secret, type: :string, aliases: '-s', desc: I18n.t('method_option.secret')
225
232
  method_option 'no-remote', type: :boolean, aliases: '-r', desc: I18n.t('method_option.noremote'), default: false
@@ -246,8 +253,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
246
253
  puts I18n.t('message.upaccount', account: account)
247
254
  end
248
255
 
249
- map 'add-role' => :add_role
250
- desc 'add-role ROLE', I18n.t('add_role.desc')
256
+ desc 'add-role ROLE', I18n.t('add_role_desc')
251
257
  method_option :arn, type: :string, aliases: '-a', desc: I18n.t('method_option.arn')
252
258
  # Add a role
253
259
  def add_role(role = nil)
@@ -267,7 +273,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
267
273
  puts I18n.t('message.addrole', role: role)
268
274
  end
269
275
 
270
- desc 'remove ACCOUNT', I18n.t('remove.desc')
276
+ desc 'remove ACCOUNT', I18n.t('remove_desc')
271
277
  # Remove an account
272
278
  def remove(account = nil)
273
279
  account = ask_check(
@@ -277,18 +283,17 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
277
283
  Awskeyring.delete_account(account: account, message: I18n.t('message.delaccount', account: account))
278
284
  end
279
285
 
280
- desc 'remove-token ACCOUNT', I18n.t('remove_token.desc')
286
+ desc 'remove-token ACCOUNT', I18n.t('remove_token_desc')
281
287
  # remove a session token
282
- def remove_token(account = nil)
283
- account = ask_check(
284
- existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:token_exists),
288
+ def remove_token(token = nil)
289
+ token = ask_check(
290
+ existing: token, message: I18n.t('message.account'), validator: Awskeyring.method(:token_exists),
285
291
  limited_to: Awskeyring.list_token_names
286
292
  )
287
- Awskeyring.delete_token(account: account, message: I18n.t('message.deltoken', account: account))
293
+ Awskeyring.delete_token(account: token, message: I18n.t('message.deltoken', account: token))
288
294
  end
289
295
 
290
- map 'remove-role' => :remove_role
291
- desc 'remove-role ROLE', I18n.t('remove_role.desc')
296
+ desc 'remove-role ROLE', I18n.t('remove_role_desc')
292
297
  # remove a role
293
298
  def remove_role(role = nil)
294
299
  role = ask_check(
@@ -298,7 +303,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
298
303
  Awskeyring.delete_role(role_name: role, message: I18n.t('message.delrole', role: role))
299
304
  end
300
305
 
301
- desc 'rotate ACCOUNT', I18n.t('rotate.desc')
306
+ desc 'rotate ACCOUNT', I18n.t('rotate_desc')
302
307
  # rotate Account keys
303
308
  def rotate(account = nil) # rubocop:disable Metrics/MethodLength
304
309
  account = ask_check(
@@ -330,8 +335,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
330
335
  puts I18n.t('message.upaccount', account: account)
331
336
  end
332
337
 
333
- desc 'token ACCOUNT [ROLE] [MFA]', I18n.t('token.desc')
334
- method_option :role, type: :string, aliases: '-r', desc: I18n.t('method_option.role')
338
+ desc 'token ACCOUNT [ROLE] [CODE]', I18n.t('token_desc')
335
339
  method_option :code, type: :string, aliases: '-c', desc: I18n.t('method_option.code')
336
340
  method_option :duration, type: :string, aliases: '-d', desc: I18n.t('method_option.duration')
337
341
  # generate a sessiopn token
@@ -342,7 +346,6 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
342
346
  validator: Awskeyring.method(:account_exists),
343
347
  limited_to: Awskeyring.list_account_names
344
348
  )
345
- role ||= options[:role]
346
349
  if role
347
350
  role = ask_check(
348
351
  existing: role, message: I18n.t('message.role'), validator: Awskeyring.method(:role_exists),
@@ -385,7 +388,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
385
388
  puts I18n.t('message.addtoken', account: account, time: Time.at(new_creds[:expiry].to_i))
386
389
  end
387
390
 
388
- desc 'console ACCOUNT', I18n.t('console.desc')
391
+ desc 'console ACCOUNT', I18n.t('console_desc')
389
392
  method_option :path, type: :string, aliases: '-p', desc: I18n.t('method_option.path')
390
393
  method_option :browser, type: :string, aliases: '-b', desc: I18n.t('method_option.browser')
391
394
  method_option 'no-token', type: :boolean, aliases: '-n', desc: I18n.t('method_option.notoken'), default: false
@@ -424,109 +427,142 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
424
427
  end
425
428
  end
426
429
 
427
- desc 'awskeyring CURR PREV', I18n.t('awskeyring.desc'), hide: true
430
+ desc "#{File.basename($PROGRAM_NAME)} CURR PREV", I18n.t('awskeyring_desc'), hide: true
431
+ map File.basename($PROGRAM_NAME) => :autocomplete
428
432
  # autocomplete
429
- def awskeyring(curr, prev)
433
+ def autocomplete(curr, prev = nil)
434
+ curr, prev = fix_args(curr, prev)
430
435
  comp_line = ENV['COMP_LINE']
431
- unless comp_line
436
+ comp_point_str = ENV['COMP_POINT']
437
+ unless comp_line && comp_point_str
432
438
  exec_name = File.basename($PROGRAM_NAME)
433
439
  warn I18n.t('message.awskeyring', path: $PROGRAM_NAME, bin: exec_name)
434
440
  exit 1
435
441
  end
436
442
 
437
- curr, comp_len, sub_cmd = comp_type(comp_line: comp_line, curr: curr, prev: prev)
438
- print_auto_resp(curr, comp_len, sub_cmd)
443
+ comp_lines = comp_line[0..(comp_point_str.to_i)].split
444
+
445
+ comp_type, sub_cmd = comp_type(comp_lines: comp_lines, prev: prev)
446
+ list = fetch_auto_resp(comp_type, sub_cmd)
447
+ puts list.select { |elem| elem.start_with?(curr) }.sort!.join("\n")
439
448
  end
440
449
 
441
450
  private
442
451
 
443
- def age_check_and_get(account:, no_token:)
444
- cred = Awskeyring.get_valid_creds(account: account, no_token: no_token)
445
-
446
- maxage = Awskeyring.key_age
447
- age = (Time.new - cred[:updated]).div Awskeyring::Awsapi::ONE_DAY
448
- warn I18n.t('message.age_check', account: account, age: age) unless age < maxage
449
-
450
- cred
452
+ # when a double dash is parsed it is dropped from the args but we need it
453
+ def fix_args(curr, prev)
454
+ if prev.nil?
455
+ [ARGV[1], ARGV[2]]
456
+ else
457
+ [curr, prev]
458
+ end
451
459
  end
452
460
 
453
- def comp_type(comp_line:, curr:, prev:)
454
- comp_len = comp_line.split.index(prev)
455
- sub_cmd = sub_command(comp_line.split)
456
-
457
- comp_len = 3 if curr.start_with?('-')
461
+ # determine the type of completion needed
462
+ def comp_type(comp_lines:, prev:)
463
+ sub_cmd = sub_command(comp_lines)
464
+ comp_idx = comp_lines.rindex(prev)
458
465
 
459
466
  case prev
460
- when 'help', File.basename($PROGRAM_NAME)
461
- comp_len = 0
462
- when 'remove-role', '-r', 'rmr'
463
- comp_len = 2
464
467
  when '--path', '-p'
465
- comp_len = 40
466
- when 'remove-token', 'rmt'
467
- comp_len = 50
468
+ comp_type = :path_type
468
469
  when '--browser', '-b'
469
- comp_len = 60
470
+ comp_type = :browser_type
471
+ else
472
+ comp_type = :command
473
+ comp_type = param_type(comp_idx, sub_cmd) unless sub_cmd.empty?
470
474
  end
471
475
 
472
- [curr, comp_len, sub_cmd]
476
+ [comp_type, sub_cmd]
477
+ end
478
+
479
+ # check params for named params or fall back to flags
480
+ def param_type(comp_idx, sub_cmd)
481
+ types = %i[opt req]
482
+ param_list = method(sub_cmd).parameters.select { |elem| types.include? elem[0] }
483
+ if comp_idx.zero?
484
+ :command
485
+ elsif comp_idx > param_list.length
486
+ :flag
487
+ else
488
+ param_list[comp_idx - 1][1]
489
+ end
473
490
  end
474
491
 
492
+ # catch the command from prefixes and aliases
475
493
  def sub_command(comp_lines)
476
- return nil if comp_lines.nil? || comp_lines.length < 2
494
+ return '' if comp_lines.nil? || comp_lines.length < 2
477
495
 
478
- sub_cmd = comp_lines[1]
496
+ sub_cmd = comp_lines[1].tr('-', '_')
479
497
 
480
- return sub_cmd if self.class.all_commands.keys.index(sub_cmd)
498
+ sub_cmds = self.class.all_commands.keys.select { |elem| elem.start_with?(sub_cmd) }
499
+
500
+ return sub_cmds.first if sub_cmds.length == 1
481
501
 
482
502
  self.class.map[sub_cmd].to_s
483
503
  end
484
504
 
485
- def print_auto_resp(curr, len, sub_cmd) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
486
- list = []
487
- case len
488
- when 0
489
- list = list_commands
490
- when 1
491
- list = Awskeyring.list_account_names
492
- when 2
493
- list = Awskeyring.list_role_names
494
- when 3..10
495
- list = list_arguments(command: sub_cmd)
496
- when 40
497
- list = Awskeyring.list_console_path
498
- when 50
499
- list = Awskeyring.list_token_names
500
- when 60
501
- list = Awskeyring.list_browsers
505
+ # given a type return the right list for completions
506
+ def fetch_auto_resp(comp_type, sub_cmd)
507
+ case comp_type
508
+ when :command
509
+ list_commands
510
+ when :account
511
+ Awskeyring.list_account_names
512
+ when :role
513
+ Awskeyring.list_role_names
514
+ when :path_type
515
+ Awskeyring.list_console_path
516
+ when :token
517
+ Awskeyring.list_token_names
518
+ when :browser_type
519
+ Awskeyring.list_browsers
502
520
  else
503
- exit 1
521
+ list_arguments(command: sub_cmd)
504
522
  end
505
- puts list.select { |elem| elem.start_with?(curr) }.sort!.join("\n")
506
523
  end
507
524
 
525
+ # list command names
508
526
  def list_commands
509
- self.class.all_commands.keys.map { |elem| elem.tr('_', '-') }.reject! { |elem| elem == 'awskeyring' }
527
+ commands = self.class.all_commands.keys.map { |elem| elem.tr('_', '-') }
528
+ commands.reject! { |elem| %w[autocomplete default].include?(elem) }
510
529
  end
511
530
 
531
+ # list flags for a command
512
532
  def list_arguments(command:)
513
- exit 1 if command.empty?
514
- self.class.all_commands[command].options.values.map(&:aliases).flatten! +
515
- self.class.all_commands[command].options.values.map(&:switch_name)
533
+ options = self.class.all_commands[command].options.values
534
+ exit 1 if options.empty?
535
+
536
+ options.map(&:aliases).flatten! +
537
+ options.map(&:switch_name)
538
+ end
539
+
540
+ # add warning about old keys
541
+ def age_check_and_get(account:, no_token:)
542
+ cred = Awskeyring.get_valid_creds(account: account, no_token: no_token)
543
+
544
+ maxage = Awskeyring.key_age
545
+ age = (Time.new - cred[:updated]).div Awskeyring::Awsapi::ONE_DAY
546
+ warn I18n.t('message.age_check', account: account, age: age) unless age < maxage
547
+
548
+ cred
516
549
  end
517
550
 
551
+ # print exports from map
518
552
  def put_env_string(cred)
519
553
  env_var = Awskeyring::Awsapi.get_env_array(cred)
520
554
  env_var.each { |var, value| puts "export #{var}=\"#{value}\"" }
521
555
  Awskeyring::Awsapi::AWS_ENV_VARS.each { |key| puts "unset #{key}" unless env_var.key?(key) }
522
556
  end
523
557
 
558
+ # select duration for sts token types
524
559
  def default_duration(duration, role, code)
525
560
  duration ||= Awskeyring::Awsapi::ONE_HOUR.to_s if role
526
561
  duration ||= Awskeyring::Awsapi::TWELVE_HOUR.to_s if code
527
562
  duration || Awskeyring::Awsapi::ONE_HOUR.to_s
528
563
  end
529
564
 
565
+ # ask and validate input values.
530
566
  def ask_check(existing:, message:, flags: nil, validator: nil, limited_to: nil) # rubocop:disable Metrics/MethodLength
531
567
  retries ||= 3
532
568
  begin
@@ -547,10 +583,12 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
547
583
  value
548
584
  end
549
585
 
586
+ # ask for somthinng if its missing.
550
587
  def ask_missing(existing:, message:, secure: false, optional: false, limited_to: nil)
551
588
  existing || ask(message: message, secure: secure, optional: optional, limited_to: limited_to).strip
552
589
  end
553
590
 
591
+ # ask in different ways
554
592
  def ask(message:, secure: false, optional: false, limited_to: nil)
555
593
  if secure
556
594
  Awskeyring::Input.read_secret("#{message.rjust(20)}: ")
@@ -563,6 +601,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
563
601
  end
564
602
  end
565
603
 
604
+ # undo Bundler env vars
566
605
  def unbundle
567
606
  to_delete = ENV.keys.select { |elem| elem.start_with?('BUNDLER_ORIG_') }
568
607
  bundled_env = to_delete.map { |elem| elem[('BUNDLER_ORIG_'.length)..] }
data/man/awskeyring.5 CHANGED
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "AWSKEYRING" "5" "November 2020" "" ""
4
+ .TH "AWSKEYRING" "5" "June 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBAwskeyring\fR \- is a small tool to manage AWS account keys in the macOS Keychain
@@ -189,17 +189,14 @@ rotate ACCOUNT:
189
189
  Rotate access keys for an ACCOUNT
190
190
  .
191
191
  .TP
192
- token ACCOUNT [ROLE] [MFA]:
192
+ token ACCOUNT [ROLE] [CODE]:
193
193
  .
194
194
  .IP
195
- Create an STS Token from a ROLE or an MFA code
195
+ Create an STS Token from a ROLE or an mfa CODE
196
196
  .
197
197
  .br
198
198
  .
199
199
  .IP
200
- \-r, \-\-role=ROLE: The ROLE to assume\.
201
- .
202
- .br
203
200
  \-c, \-\-code=CODE: Virtual mfa CODE\.
204
201
  .
205
202
  .br
@@ -267,8 +264,34 @@ awskeyring env personal\-aws
267
264
  .
268
265
  .IP "" 0
269
266
  .
267
+ .P
268
+ To open the AWS Console (web page) with your default browser simply run\.\.\.
269
+ .
270
+ .IP "" 4
271
+ .
272
+ .nf
273
+
274
+ awskeyring console personal\-aws
275
+ .
276
+ .fi
277
+ .
278
+ .IP "" 0
279
+ .
280
+ .P
281
+ Autocomplete is enabled in your current shell with the following command\.\.\.
282
+ .
283
+ .IP "" 4
284
+ .
285
+ .nf
286
+
287
+ complete \-C /usr/local/bin/awskeyring awskeyring
288
+ .
289
+ .fi
290
+ .
291
+ .IP "" 0
292
+ .
270
293
  .SH "HISTORY"
271
- The motivation of this application is to provide a local secure store of AWS credentials using specifically in the macOS Keychain, to have them easily accessed from the Terminal, and to provide useful functions like assuming roles and opening the AWS Console from the cli\. For Enterprise environments there are better suited tools to use like HashiCorp Vault \fIhttps://vaultproject\.io/\fR\.
294
+ The motivation of this application is to provide a local secure store of AWS credentials using specifically in the macOS Keychain, to have them easily accessed from the Terminal, and to provide useful functions like assuming roles and opening the AWS Console from the cli\. It then expanded to include autocomplete and a desire to have an almost complete test coverage to prevent regressions in its functionality\. For Enterprise environments there are better suited tools to use like HashiCorp Vault \fIhttps://vaultproject\.io/\fR\.
272
295
  .
273
296
  .SH "SECURITY"
274
297
  If you believe you have found a security issue in Awskeyring, please responsibly disclose by contacting me at \fItristan\.morgan@servian\.com\fR\. Awskeyring is a Ruby script and as such Ruby is whitelisted to access your "awskeyring" keychain\. Use a strong password and keep the unlock time short\.
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: 1.8.0
4
+ version: 1.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tristan Morgan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-07 00:00:00.000000000 Z
11
+ date: 2021-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-iam
@@ -73,14 +73,10 @@ executables:
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - CHANGELOG.md
77
- - CODE_OF_CONDUCT.md
78
- - CONTRIBUTING.md
79
76
  - Gemfile
80
77
  - LICENSE.txt
81
78
  - README.md
82
79
  - Rakefile
83
- - SECURITY.md
84
80
  - awskeyring.gemspec
85
81
  - exe/awskeyring
86
82
  - i18n/en.yml
@@ -91,15 +87,14 @@ files:
91
87
  - lib/awskeyring/version.rb
92
88
  - lib/awskeyring_command.rb
93
89
  - man/awskeyring.5
94
- - man/awskeyring.5.ronn
95
90
  homepage: https://github.com/servian/awskeyring
96
91
  licenses:
97
92
  - MIT
98
93
  metadata:
99
94
  bug_tracker_uri: https://github.com/servian/awskeyring/issues
100
95
  changelog_uri: https://github.com/servian/awskeyring/blob/main/CHANGELOG.md
101
- documentation_uri: https://rubydoc.info/gems/awskeyring/1.8.0
102
- source_code_uri: https://github.com/servian/awskeyring/tree/v1.8.0
96
+ documentation_uri: https://rubydoc.info/gems/awskeyring/1.8.5
97
+ source_code_uri: https://github.com/servian/awskeyring/tree/v1.8.5
103
98
  wiki_uri: https://github.com/servian/awskeyring/wiki
104
99
  post_install_message:
105
100
  rdoc_options: []
data/CHANGELOG.md DELETED
@@ -1,152 +0,0 @@
1
- # Changelog
2
-
3
- ## [v1.8.0](https://github.com/servian/awskeyring/tree/v1.8.0) (2020-12-07)
4
-
5
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.7.0...v1.8.0)
6
-
7
- **Implemented enhancements:**
8
-
9
- - Include expiry time export, AWS\_CREDENTIAL\_EXPIRATION [\#74](https://github.com/servian/awskeyring/pull/74) ([tristanmorgan](https://github.com/tristanmorgan))
10
-
11
- ## [v1.7.0](https://github.com/servian/awskeyring/tree/v1.7.0) (2020-11-18)
12
-
13
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.6.0...v1.7.0)
14
-
15
- **Implemented enhancements:**
16
-
17
- - Allow specifying a browser other than the default [\#71](https://github.com/servian/awskeyring/issues/71)
18
- - Autocomplete for Browsers [\#73](https://github.com/servian/awskeyring/pull/73) ([tristanmorgan](https://github.com/tristanmorgan))
19
-
20
- **Merged pull requests:**
21
-
22
- - Updates for added RuboCop checks. [\#70](https://github.com/servian/awskeyring/pull/70) ([tristanmorgan](https://github.com/tristanmorgan))
23
-
24
- ## [v1.6.0](https://github.com/servian/awskeyring/tree/v1.6.0) (2020-08-11)
25
-
26
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.5.0...v1.6.0)
27
-
28
- **Implemented enhancements:**
29
-
30
- - Warn about missing accounts/roles [\#69](https://github.com/servian/awskeyring/pull/69) ([tristanmorgan](https://github.com/tristanmorgan))
31
- - RuboCop and Spec update [\#68](https://github.com/servian/awskeyring/pull/68) ([tristanmorgan](https://github.com/tristanmorgan))
32
- - Add SimpleCov reports. [\#67](https://github.com/servian/awskeyring/pull/67) ([tristanmorgan](https://github.com/tristanmorgan))
33
-
34
- ## [v1.5.0](https://github.com/servian/awskeyring/tree/v1.5.0) (2020-07-08)
35
-
36
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.4.0...v1.5.0)
37
-
38
- **Implemented enhancements:**
39
-
40
- - No-Bundle env changes for exec. [\#66](https://github.com/servian/awskeyring/pull/66) ([tristanmorgan](https://github.com/tristanmorgan))
41
-
42
- ## [v1.4.0](https://github.com/servian/awskeyring/tree/v1.4.0) (2020-06-19)
43
-
44
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.3.3...v1.4.0)
45
-
46
- **Implemented enhancements:**
47
-
48
- - Import Keys and Tokens from shared credentials files. [\#65](https://github.com/servian/awskeyring/pull/65) ([tristanmorgan](https://github.com/tristanmorgan))
49
-
50
- ## [v1.3.3](https://github.com/servian/awskeyring/tree/v1.3.3) (2020-06-04)
51
-
52
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.3.2...v1.3.3)
53
-
54
- **Implemented enhancements:**
55
-
56
- - Change email references from Vibrato to Servian [\#64](https://github.com/servian/awskeyring/pull/64) ([tristanmorgan](https://github.com/tristanmorgan))
57
-
58
- ## [v1.3.2](https://github.com/servian/awskeyring/tree/v1.3.2) (2020-04-27)
59
-
60
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.3.1...v1.3.2)
61
-
62
- **Fixed bugs:**
63
-
64
- - Fix I18n message load when used as a library. [\#63](https://github.com/servian/awskeyring/pull/63) ([tristanmorgan](https://github.com/tristanmorgan))
65
-
66
- ## [v1.3.1](https://github.com/servian/awskeyring/tree/v1.3.1) (2020-03-19)
67
-
68
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.3.0...v1.3.1)
69
-
70
- **Implemented enhancements:**
71
-
72
- - Markdown linting changes and removed Rubocop-MD. [\#61](https://github.com/servian/awskeyring/pull/61) ([tristanmorgan](https://github.com/tristanmorgan))
73
- - Removed some redundant code. [\#60](https://github.com/servian/awskeyring/pull/60) ([tristanmorgan](https://github.com/tristanmorgan))
74
-
75
- **Merged pull requests:**
76
-
77
- - Update Ronn code and PR template. [\#59](https://github.com/servian/awskeyring/pull/59) ([tristanmorgan](https://github.com/tristanmorgan))
78
-
79
- ## [v1.3.0](https://github.com/servian/awskeyring/tree/v1.3.0) (2020-02-19)
80
-
81
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.2.0...v1.3.0)
82
-
83
- **Implemented enhancements:**
84
-
85
- - Add a man-page and tweak README. [\#58](https://github.com/servian/awskeyring/pull/58) ([tristanmorgan](https://github.com/tristanmorgan))
86
- - Enhanced version [\#57](https://github.com/servian/awskeyring/pull/57) ([AzySir](https://github.com/AzySir))
87
-
88
- ## [v1.2.0](https://github.com/servian/awskeyring/tree/v1.2.0) (2020-01-20)
89
-
90
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.1.2...v1.2.0)
91
-
92
- **Implemented enhancements:**
93
-
94
- - Check for existing account keys and role arns [\#56](https://github.com/servian/awskeyring/pull/56) ([tristanmorgan](https://github.com/tristanmorgan))
95
-
96
- ## [v1.1.2](https://github.com/servian/awskeyring/tree/v1.1.2) (2020-01-06)
97
-
98
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.1.1...v1.1.2)
99
-
100
- **Fixed bugs:**
101
-
102
- - Deprecation warning for exit\_on\_failure [\#55](https://github.com/servian/awskeyring/pull/55) ([tristanmorgan](https://github.com/tristanmorgan))
103
-
104
- ## [v1.1.1](https://github.com/servian/awskeyring/tree/v1.1.1) (2019-11-27)
105
-
106
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.1.0...v1.1.1)
107
-
108
- **Implemented enhancements:**
109
-
110
- - Add --detail flag for roles. [\#54](https://github.com/servian/awskeyring/pull/54) ([tristanmorgan](https://github.com/tristanmorgan))
111
-
112
- ## [v1.1.0](https://github.com/servian/awskeyring/tree/v1.1.0) (2019-11-06)
113
-
114
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.0.2...v1.1.0)
115
-
116
- **Implemented enhancements:**
117
-
118
- - Add completion to input prompts [\#53](https://github.com/servian/awskeyring/pull/53) ([tristanmorgan](https://github.com/tristanmorgan))
119
- - Check for existing \(or not\) role names [\#52](https://github.com/servian/awskeyring/pull/52) ([tristanmorgan](https://github.com/tristanmorgan))
120
-
121
- ## [v1.0.2](https://github.com/servian/awskeyring/tree/v1.0.2) (2019-10-18)
122
-
123
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.0.1...v1.0.2)
124
-
125
- **Implemented enhancements:**
126
-
127
- - Move to a new home, Servian. [\#51](https://github.com/servian/awskeyring/pull/51) ([tristanmorgan](https://github.com/tristanmorgan))
128
- - Use RuboCop-RSpec too and expect\(\) more. [\#48](https://github.com/servian/awskeyring/pull/48) ([tristanmorgan](https://github.com/tristanmorgan))
129
-
130
- ## [v1.0.1](https://github.com/servian/awskeyring/tree/v1.0.1) (2019-05-23)
131
-
132
- [Full Changelog](https://github.com/servian/awskeyring/compare/v1.0.0...v1.0.1)
133
-
134
- **Implemented enhancements:**
135
-
136
- - auto-complete the --version [\#47](https://github.com/servian/awskeyring/pull/47) ([tristanmorgan](https://github.com/tristanmorgan))
137
-
138
- **Fixed bugs:**
139
-
140
- - Unfreeze secret strings. [\#46](https://github.com/servian/awskeyring/pull/46) ([tristanmorgan](https://github.com/tristanmorgan))
141
-
142
- ## [v1.0.0](https://github.com/servian/awskeyring/tree/v1.0.0) (2019-05-19)
143
-
144
- [Full Changelog](https://github.com/servian/awskeyring/compare/v0.10.0...v1.0.0)
145
-
146
- **Implemented enhancements:**
147
-
148
- - More RuboCop changes and tweaked version string. [\#45](https://github.com/servian/awskeyring/pull/45) ([tristanmorgan](https://github.com/tristanmorgan))
149
-
150
-
151
-
152
- \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/CODE_OF_CONDUCT.md DELETED
@@ -1,73 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- education, socio-economic status, nationality, personal appearance, race,
10
- religion, or sexual identity and orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at [tristan.morgan@servian.com](mailto:tristan.morgan@servian.com). All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available [here](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html)
72
-
73
- [homepage]: https://www.contributor-covenant.org
data/CONTRIBUTING.md DELETED
@@ -1,48 +0,0 @@
1
- # How to contribute
2
-
3
- Bug reports and pull requests from users are what keep this project working.
4
-
5
- ## Basics
6
-
7
- 1. Create an issue and describe your idea
8
- 2. [Fork it](https://github.com/servian/awskeyring/fork)
9
- 3. Create your feature branch (`git checkout -b my-new-feature`)
10
- 4. Commit your changes (`git commit -am 'Add some feature'`)
11
- 5. Publish the branch (`git push origin my-new-feature`)
12
- 6. Create a new Pull Request
13
-
14
- ## Checking your work
15
-
16
- You can run the test suite.
17
-
18
- You can run [RuboCop] to check code style.
19
-
20
- You can run [RSpec] to see if anything broke.
21
-
22
- You can run [YARD] to see of your code is documented.
23
-
24
- The default Rake task, runnable using `rake`.
25
-
26
- ## Write documentation
27
-
28
- This project has documentation in a few places:
29
-
30
- ### Introduction and usage
31
-
32
- A friendly `README.md` written for many audiences.
33
-
34
- ### Examples and advanced usage
35
-
36
- The [wiki].
37
-
38
- ### API documentation
39
-
40
- API documentation is written as [YARD] docblocks in the Ruby code.
41
-
42
- This is rendered as Web pages on [Rubydoc.info][awskeyring on Rubydoc.info].
43
-
44
- [wiki]: https://github.com/servian/awskeyring/wiki
45
- [YARD]: https://yardoc.org/
46
- [awskeyring on Rubydoc.info]: https://www.rubydoc.info/gems/awskeyring
47
- [RuboCop]: https://rubocop.readthedocs.io/en/latest/
48
- [Rspec]: https://rspec.info
data/SECURITY.md DELETED
@@ -1,4 +0,0 @@
1
- # Security Policy
2
-
3
- If you believe you have found a security issue in Awskeyring, please responsibly disclose by contacting me at
4
- [tristan.morgan@servian.com](mailto:tristan.morgan@servian.com).
@@ -1,175 +0,0 @@
1
- # Awskeyring -- is a small tool to manage AWS account keys in the macOS Keychain
2
-
3
- ## SYNOPSIS
4
-
5
- awskeyring COMMAND [ACCOUNT|ROLE] [OPTIONS]
6
-
7
- awskeyring help COMMAND
8
-
9
- ## DESCRIPTION
10
-
11
- The Awskeyring utility stores and manages AWS access keys and provides the facility to generate access tokens with
12
- combinations of assumed roles and multi-factor-authentication codes. It includes autocompletion features and multiple
13
- validation checks for input parsing. It also includes the ability for the AWS CLI to call it directly to provide authentication.
14
-
15
- The commands are as follows:
16
-
17
- * --version, -v:
18
-
19
- Prints the version<br>
20
-
21
- -r, --no-remote: Do not validate with remote api.
22
-
23
- * add ACCOUNT:
24
-
25
- Adds an ACCOUNT to the keyring<br>
26
-
27
- -k, --key=KEY: AWS account key id.<br>
28
- -s, --secret=SECRET: AWS account secret.<br>
29
- -m, --mfa=MFA: AWS virtual mfa arn.<br>
30
- -r, --no-remote: Do not validate with remote api.
31
-
32
- * add-role ROLE:
33
-
34
- Adds a ROLE to the keyring<br>
35
-
36
- -a, --arn=ARN: AWS role arn.
37
-
38
- * awskeyring console ACCOUNT:
39
-
40
- Open the AWS Console for the ACCOUNT<br>
41
-
42
- -p, --path=PATH: The service PATH to open.<br>
43
- -b, --browser=BROWSER: Specify an alternative browser.<br>
44
- -n, --no-token: Do not use saved token.<br>
45
- -o, --no-open: Do not open the url.
46
-
47
- * env ACCOUNT:
48
-
49
- Outputs bourne shell environment exports for an ACCOUNT<br>
50
-
51
- -n, --no-token: Do not use saved token.<br>
52
- -u, --unset, --no-unset: Unset environment variables.
53
-
54
- * exec ACCOUNT command...:
55
-
56
- Execute a COMMAND with the environment set for an ACCOUNT<br>
57
-
58
- -n, --no-token: Do not use saved token.<br>
59
- -b, --no-bundle: Unset Bundler environment variables.
60
-
61
- * help [COMMAND]:
62
-
63
- Describe available commands or one specific command
64
-
65
- * import:
66
-
67
- Import an ACCOUNT to the keyring from ~/.aws/credentials<br>
68
-
69
- -r, --no-remote: Do not validate with remote api.
70
-
71
- * initialise:
72
-
73
- Initialises a new KEYCHAIN<br>
74
-
75
- -n, --keychain=KEYCHAIN: Name of KEYCHAIN to initialise.
76
-
77
- * json ACCOUNT:
78
-
79
- Outputs AWS CLI compatible JSON for an ACCOUNT<br>
80
-
81
- -n, --no-token: Do not use saved token.
82
-
83
- * list:
84
-
85
- Prints a list of accounts in the keyring
86
-
87
- * list-role:
88
-
89
- Prints a list of roles in the keyring<br>
90
-
91
- -d, --detail, --no-detail: Show more detail.
92
-
93
- * remove ACCOUNT:
94
-
95
- Removes an ACCOUNT from the keyring
96
-
97
- * remove-role ROLE:
98
-
99
- Removes a ROLE from the keyring
100
-
101
- * remove-token ACCOUNT:
102
-
103
- Removes a token for ACCOUNT from the keyring
104
-
105
- * rotate ACCOUNT:
106
-
107
- Rotate access keys for an ACCOUNT
108
-
109
- * token ACCOUNT [ROLE] [MFA]:
110
-
111
- Create an STS Token from a ROLE or an MFA code<br>
112
-
113
- -r, --role=ROLE: The ROLE to assume.<br>
114
- -c, --code=CODE: Virtual mfa CODE.<br>
115
- -d, --duration=DURATION: Session DURATION in seconds.
116
-
117
- * update ACCOUNT:
118
-
119
- Updates an ACCOUNT in the keyring<br>
120
-
121
- -k, --key=KEY: AWS account key id.<br>
122
- -s, --secret=SECRET: AWS account secret.<br>
123
- -r, --no-remote: Do not validate with remote api.
124
-
125
- ## ENVIRONMENT
126
-
127
- The AWS_DEFAULT_REGION environment variable will be used for AWS API calls where specified or fall back to us-east-1
128
- when not.
129
-
130
- ## EXIT STATUS
131
-
132
- The Awskeyring utility exits 0 on success, and >0 if an error occurs.
133
-
134
- ## EXAMPLES
135
-
136
- First you need to initialise your keychain to hold your AWS credentials.
137
-
138
- awskeyring initialise
139
-
140
- Then add your keys to it.
141
-
142
- awskeyring add personal-aws
143
-
144
- Now your keys are stored safely in the macOS keychain. To print environment variables run...
145
-
146
- awskeyring env personal-aws
147
-
148
- ## HISTORY
149
-
150
- The motivation of this application is to provide a local secure store of AWS
151
- credentials using specifically in the macOS Keychain, to have them easily accessed
152
- from the Terminal, and to provide useful functions like assuming roles and opening
153
- the AWS Console from the cli.
154
- For Enterprise environments there are better suited tools to use
155
- like [HashiCorp Vault](https://vaultproject.io/).
156
-
157
- ## SECURITY
158
-
159
- If you believe you have found a security issue in Awskeyring, please responsibly disclose by contacting me at
160
- [tristan.morgan@servian.com](mailto:tristan.morgan@servian.com). Awskeyring is a Ruby script and as such Ruby is whitelisted to
161
- access your "awskeyring" keychain. Use a strong password and keep the unlock time short.
162
-
163
- ## AUTHOR
164
-
165
- Tristan Morgan <tristan.morgan@servian.com> is the maintainer of Awskeyring.
166
-
167
- ## CONTRIBUTORS
168
-
169
- * Tristan [tristanmorgan](https://github.com/tristanmorgan)
170
- * Adam Sir [AzySir](https://github.com/AzySir)
171
- * Vito Giarrusso [thtliife](https://github.com/thtliife)
172
-
173
- ## LICENSE
174
-
175
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).