aws-keychain-util 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -0
- data/README.md +37 -2
- data/Rakefile +6 -1
- data/aws-keychain-util.gemspec +13 -11
- data/bin/aws-creds +185 -79
- data/lib/aws-keychain-util/credential_provider.rb +7 -9
- data/lib/{aws-keychain-util.rb → aws_keychain_util.rb} +2 -1
- metadata +34 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90edd8647b398a66b149ca02c9d6790b6e7d6a1e
|
4
|
+
data.tar.gz: 9dfa7feb0b5fe3b00147704f9135fdc89a724cef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0478d2ca301dda7bf6866bf4c237caf9b01bec3f8934de48422e3b1a202d23f31f47ce0595b9764603fd9aba70e83656d7a44384dcc080d211e2c2d084b2d6cc
|
7
|
+
data.tar.gz: d6ba9c8718e9c7a4ddbc7a11502a00c430eb35006d134005336010667f62ffea3acf37e1d546639aee9aa9fcc3b4f86754d8f5bfa033b2c9a0c30bc92e66d1a9
|
data/.rubocop.yml
ADDED
data/README.md
CHANGED
@@ -53,15 +53,29 @@ you can source into your shell:
|
|
53
53
|
|
54
54
|
$ aws-creds env <name>
|
55
55
|
|
56
|
+
If you want to load the credentials into your *current* shell, add a function
|
57
|
+
like this to your `.bashrc`:
|
58
|
+
|
59
|
+
aws-shell() { eval "$(/usr/bin/env aws-creds env $@)"; }
|
60
|
+
|
61
|
+
Then, you can use `aws-shell <name>`. This can be slightly more convenient as
|
62
|
+
you keep shell history around.
|
63
|
+
|
56
64
|
To always load the given environment in your shell, add the following to
|
57
65
|
your .bashrc or .zshrc
|
58
66
|
|
59
|
-
|
67
|
+
eval "$(aws-creds env <name>)"
|
60
68
|
|
61
69
|
To automatically grab AWS credentials from your keychain when using
|
62
70
|
the aws-sdk gem, add the following code:
|
63
71
|
|
64
|
-
|
72
|
+
require 'aws-keychain-util/credential_provider'
|
73
|
+
Aws.config[:credentials] = AwsKeychainUtil::CredentialProvider.new('<name>', 'keychain name')
|
74
|
+
|
75
|
+
To remove an item from your aws keychain:
|
76
|
+
|
77
|
+
$ aws-creds rm <name>
|
78
|
+
|
65
79
|
|
66
80
|
## AWS Multi-Factor Authentication (MFA)
|
67
81
|
|
@@ -86,6 +100,27 @@ The tool also tracks mfa expiration, and automatically removes expired tokens wh
|
|
86
100
|
or source your env.
|
87
101
|
|
88
102
|
|
103
|
+
## AWS Assume Role credentials
|
104
|
+
|
105
|
+
It's also possible assume a role that specifies a set of permissions that you can use to access
|
106
|
+
AWS resources that you need for a limited time. The role can be in your own account or any other AWS account.
|
107
|
+
|
108
|
+
For information about how to create and configure Roles, see
|
109
|
+
IAM Roles[Here](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html)
|
110
|
+
|
111
|
+
In order to configure a role run:
|
112
|
+
|
113
|
+
$ aws-creds add-role <name>
|
114
|
+
|
115
|
+
Then to assume a role, you need to run:
|
116
|
+
|
117
|
+
$ aws-creds assume-role <name> <role-name>
|
118
|
+
|
119
|
+
Then you just need to either open a fresh shell for the `<name>` key or re-source your environment.
|
120
|
+
|
121
|
+
The tool also tracks role expiration, and automatically removes expired tokens when you open a new shell
|
122
|
+
or source your env.
|
123
|
+
|
89
124
|
## Security
|
90
125
|
|
91
126
|
Unfortunately, when Keychain whitelists either the `aws-creds` script
|
data/Rakefile
CHANGED
data/aws-keychain-util.gemspec
CHANGED
@@ -3,20 +3,22 @@ lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
|
-
gem.name =
|
7
|
-
gem.version = '0.0.
|
8
|
-
gem.authors = [
|
9
|
-
gem.email = [
|
10
|
-
gem.description =
|
11
|
-
gem.summary =
|
12
|
-
gem.homepage =
|
6
|
+
gem.name = 'aws-keychain-util'
|
7
|
+
gem.version = '0.0.13'
|
8
|
+
gem.authors = ['Zach Wily']
|
9
|
+
gem.email = ['zach@zwily.com']
|
10
|
+
gem.description = 'Helps manage a keychain of AWS credentials on OS X.'
|
11
|
+
gem.summary = 'Helps manage a keychain of AWS credentials on OS X.'
|
12
|
+
gem.homepage = ''
|
13
13
|
|
14
|
-
gem.files = `git ls-files`.split(
|
15
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
16
16
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
-
gem.require_paths = [
|
17
|
+
gem.require_paths = ['lib']
|
18
18
|
|
19
19
|
gem.add_dependency('ruby-keychain', '~> 0.2.0')
|
20
20
|
gem.add_dependency('highline')
|
21
|
-
gem.add_dependency('aws-sdk
|
21
|
+
gem.add_dependency('aws-sdk', '> 2.0')
|
22
|
+
gem.add_development_dependency 'rubocop'
|
23
|
+
gem.add_development_dependency 'rake'
|
22
24
|
end
|
data/bin/aws-creds
CHANGED
@@ -1,15 +1,22 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
if $
|
4
|
-
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) +
|
3
|
+
if $PROGRAM_NAME == 'bin/aws-creds'
|
4
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + '/../lib')
|
5
5
|
end
|
6
6
|
|
7
7
|
require 'rubygems'
|
8
8
|
require 'highline'
|
9
9
|
require 'keychain'
|
10
10
|
require 'json'
|
11
|
-
require '
|
12
|
-
require 'aws-sdk
|
11
|
+
require 'aws_keychain_util'
|
12
|
+
require 'aws-sdk'
|
13
|
+
|
14
|
+
trap('SIGINT') do
|
15
|
+
puts
|
16
|
+
$stderr.puts "\nExecution aborted."
|
17
|
+
puts
|
18
|
+
exit 1
|
19
|
+
end
|
13
20
|
|
14
21
|
def ask(question)
|
15
22
|
HighLine.new.ask(question)
|
@@ -22,53 +29,74 @@ end
|
|
22
29
|
def load_keychain
|
23
30
|
keychain = AwsKeychainUtil.load_keychain
|
24
31
|
if keychain && keychain.lock_interval > 300
|
25
|
-
$stderr.puts
|
26
|
-
|
27
|
-
$stderr.puts "You should probably run `#{$
|
32
|
+
$stderr.puts 'Your keychain is *not* set to lock automatically in under five minutes. This could be dangerous.'
|
33
|
+
unless File.exist? AwsKeychainUtil::PREFS_FILE
|
34
|
+
$stderr.puts "You should probably run `#{$PROGRAM_NAME} init` to create a new, secure keychain."
|
28
35
|
end
|
29
36
|
end
|
30
37
|
keychain
|
31
38
|
end
|
32
39
|
|
33
40
|
def get_item(name)
|
34
|
-
load_keychain.generic_passwords.where(:
|
41
|
+
load_keychain.generic_passwords.where(label: name).first
|
42
|
+
end
|
43
|
+
|
44
|
+
def delete_expired(key, token)
|
45
|
+
expires_at = Time.at(key.attributes[:comment].to_i)
|
46
|
+
if expires_at < Time.now
|
47
|
+
delete_pair(key, token, '# Removing expired STS credentials')
|
48
|
+
key = nil
|
49
|
+
token = nil
|
50
|
+
end
|
51
|
+
[key, token]
|
52
|
+
end
|
53
|
+
|
54
|
+
def delete_pair(key, token, message)
|
55
|
+
puts message
|
56
|
+
token.delete if token
|
57
|
+
key.delete if key
|
35
58
|
end
|
36
59
|
|
37
60
|
def get_name_from_args_for_command(command)
|
38
|
-
if ARGV.
|
39
|
-
puts "Usage: #{$
|
61
|
+
if ARGV.empty?
|
62
|
+
puts "Usage: #{$PROGRAM_NAME} #{command} <name>"
|
40
63
|
exit 1
|
41
64
|
end
|
42
65
|
ARGV.shift
|
43
66
|
end
|
44
67
|
|
68
|
+
def get_valid_item(name)
|
69
|
+
item = get_item(name)
|
70
|
+
unless item
|
71
|
+
puts "Could not find item with name #{name}"
|
72
|
+
exit 1
|
73
|
+
end
|
74
|
+
item
|
75
|
+
end
|
76
|
+
|
45
77
|
def get_item_from_args_for_command(command)
|
46
78
|
name = get_name_from_args_for_command(command)
|
79
|
+
|
80
|
+
role_key = get_item("#{name} role-key")
|
81
|
+
role_token = get_item("#{name} role-token")
|
82
|
+
role_key, role_token = delete_expired(role_key, role_token) if role_key
|
83
|
+
|
47
84
|
item_mfa = get_item("#{name} mfa")
|
48
85
|
item_token = get_item("#{name} token")
|
49
|
-
if item_mfa
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
item_token.delete
|
55
|
-
item_token = nil
|
56
|
-
item_mfa.delete
|
57
|
-
item_mfa = nil
|
58
|
-
end
|
59
|
-
end
|
86
|
+
item_mfa, item_token = delete_expired(item_mfa, item_token) if item_mfa
|
87
|
+
|
88
|
+
if role_key && role_token
|
89
|
+
puts '# Using temporary STS role credentials'
|
90
|
+
return role_key, role_token
|
60
91
|
end
|
61
|
-
|
62
|
-
|
92
|
+
|
93
|
+
if item_mfa && item_token
|
94
|
+
puts '# Using temporary STS credentials'
|
63
95
|
return item_mfa, item_token
|
64
96
|
end
|
65
97
|
|
66
|
-
item =
|
67
|
-
|
68
|
-
puts "Could not find item with name #{name}"
|
69
|
-
exit 1
|
70
|
-
end
|
71
|
-
return item, nil
|
98
|
+
item = get_valid_item(name)
|
99
|
+
[item, nil]
|
72
100
|
end
|
73
101
|
|
74
102
|
command = ARGV.shift
|
@@ -81,107 +109,182 @@ when 'init'
|
|
81
109
|
end
|
82
110
|
|
83
111
|
name = ask("Name for AWS keychain (default: 'aws'): ")
|
84
|
-
name =
|
112
|
+
name = 'aws' if name == ''
|
85
113
|
|
86
114
|
shell_arguments = ask("Shell arguments (default: '--login'): ")
|
87
|
-
shell_arguments =
|
115
|
+
shell_arguments = '--login' if shell_arguments == ''
|
88
116
|
|
89
|
-
puts
|
117
|
+
puts 'The OS will now ask you for a password to protect your keychain. Choose wisely.'
|
90
118
|
keychain = Keychain.create(name)
|
91
119
|
keychain.lock_interval = 300
|
92
120
|
keychain.lock_on_sleep = true
|
93
121
|
|
94
122
|
$prefs = { 'aws_keychain_name' => name, 'shell_arguments' => shell_arguments }
|
95
|
-
File.new(AwsKeychainUtil::PREFS_FILE,
|
123
|
+
File.new(AwsKeychainUtil::PREFS_FILE, 'w').write JSON.dump($prefs)
|
96
124
|
|
97
|
-
puts
|
98
|
-
puts
|
99
|
-
puts
|
125
|
+
puts 'Your AWS keychain has been created and configured to auto-lock after'
|
126
|
+
puts '5 minutes, and when sleeping. You can change those options in'
|
127
|
+
puts 'Keychain Access.'
|
100
128
|
puts
|
101
|
-
puts
|
102
|
-
puts " #{$
|
129
|
+
puts 'You can now add accounts to the keychain with:'
|
130
|
+
puts " #{$PROGRAM_NAME} add"
|
103
131
|
|
104
132
|
when 'ls'
|
105
133
|
keychain = load_keychain
|
106
|
-
keychain.generic_passwords.all.sort
|
134
|
+
items = keychain.generic_passwords.all.sort do |a, b|
|
107
135
|
a.attributes[:label] <=> b.attributes[:label]
|
108
|
-
|
136
|
+
end
|
137
|
+
items.each do |item|
|
109
138
|
puts " #{item.attributes[:label]}"
|
110
139
|
end
|
111
140
|
|
112
141
|
when 'add'
|
113
142
|
keychain = load_keychain
|
114
|
-
name = ask(
|
115
|
-
account = ask(
|
116
|
-
password = ask_secure(
|
117
|
-
arn = ask(
|
143
|
+
name = ask(' account name: ')
|
144
|
+
account = ask(' access key id: ')
|
145
|
+
password = ask_secure(' secret_access_key: ')
|
146
|
+
arn = ask(' mfa arn: ')
|
118
147
|
|
119
148
|
item = keychain.generic_passwords.create(
|
120
|
-
:
|
121
|
-
:
|
122
|
-
:
|
123
|
-
:
|
149
|
+
label: name,
|
150
|
+
account: account,
|
151
|
+
password: password,
|
152
|
+
comment: arn
|
124
153
|
)
|
125
154
|
|
126
155
|
when 'cat'
|
127
156
|
item, token = get_item_from_args_for_command('cat')
|
128
157
|
puts "AWS_ACCESS_KEY_ID=#{item.attributes[:account]}"
|
129
158
|
puts "AWS_SECRET_ACCESS_KEY=#{item.password}"
|
130
|
-
if token
|
131
|
-
puts "AWS_SECURITY_TOKEN=#{token.password}"
|
132
|
-
end
|
159
|
+
puts "AWS_SECURITY_TOKEN=#{token.password}" if token
|
133
160
|
|
134
161
|
when 'rm'
|
135
162
|
item, token = get_item_from_args_for_command('rm')
|
136
|
-
item
|
163
|
+
delete_pair(item, token, '# Removing credentials')
|
164
|
+
|
165
|
+
when 'add-role'
|
166
|
+
keychain = load_keychain
|
167
|
+
name = get_name_from_args_for_command('add-role')
|
168
|
+
item = get_valid_item(name)
|
169
|
+
|
170
|
+
role = ask(' role name: ')
|
171
|
+
arn = ask(' role arn: ')
|
172
|
+
|
173
|
+
keychain.generic_passwords.create(
|
174
|
+
label: "#{name} role #{role}",
|
175
|
+
account: role,
|
176
|
+
password: '',
|
177
|
+
comment: arn
|
178
|
+
)
|
179
|
+
|
180
|
+
when 'assume-role'
|
181
|
+
keychain = load_keychain
|
182
|
+
name = ARGV.shift
|
183
|
+
role_name = ARGV.shift
|
184
|
+
code = ARGV.shift
|
185
|
+
|
186
|
+
unless name
|
187
|
+
puts "Usage: #{$PROGRAM_NAME} assume-role <name> <role-name> [<mfa>]"
|
188
|
+
exit 1
|
189
|
+
end
|
190
|
+
|
191
|
+
item = get_valid_item(name)
|
192
|
+
|
193
|
+
role_key = get_item("#{name} role-key")
|
194
|
+
role_token = get_item("#{name} role-token")
|
195
|
+
delete_pair(role_key, role_token, '# Removing STS role credentials') if role_key
|
196
|
+
|
197
|
+
sts_item = get_item("#{name} mfa")
|
198
|
+
sts_token = get_item("#{name} token")
|
199
|
+
delete_pair(sts_item, sts_token, '# Removing STS credentials') if sts_item
|
200
|
+
|
201
|
+
exit 0 if 'none' == role_name || role_name.nil?
|
202
|
+
|
203
|
+
item_role = get_valid_item("#{name} role #{role_name}")
|
204
|
+
|
205
|
+
sts = Aws::STS::Client.new(access_key_id: item.attributes[:account], secret_access_key: item.password)
|
206
|
+
|
207
|
+
begin
|
208
|
+
if code
|
209
|
+
response = sts.assume_role(duration_seconds: (60 * 60 * 1),
|
210
|
+
role_arn: item_role.attributes[:comment],
|
211
|
+
role_session_name: item_role.attributes[:account],
|
212
|
+
serial_number: item.attributes[:comment],
|
213
|
+
token_code: code)
|
214
|
+
else
|
215
|
+
response = sts.assume_role(duration_seconds: (60 * 60 * 1),
|
216
|
+
role_arn: item_role.attributes[:comment],
|
217
|
+
role_session_name: item_role.attributes[:account])
|
218
|
+
end
|
219
|
+
keychain.generic_passwords.create(label: "#{name} role-key",
|
220
|
+
account: response.credentials[:access_key_id],
|
221
|
+
password: response.credentials[:secret_access_key],
|
222
|
+
comment: response.credentials[:expiration].to_i.to_s)
|
223
|
+
keychain.generic_passwords.create(label: "#{name} role-token",
|
224
|
+
account: "#{response.credentials[:access_key_id]}_token",
|
225
|
+
password: response.credentials[:session_token],
|
226
|
+
comment: "#{name} role #{role_name}")
|
227
|
+
|
228
|
+
puts "AssumeRoleAuthentication succeeded, expiration is #{response.credentials[:expiration]}"
|
229
|
+
rescue Aws::STS::Errors::AccessDenied => e
|
230
|
+
puts e.to_s
|
231
|
+
end
|
137
232
|
|
138
233
|
when 'mfa'
|
139
234
|
keychain = load_keychain
|
140
235
|
item_name = ARGV.shift
|
141
236
|
code = ARGV.shift
|
142
|
-
if
|
143
|
-
puts "Usage:
|
144
|
-
exit
|
237
|
+
if !item_name || !code
|
238
|
+
puts "Usage: #{$PROGRAM_NAME} mfa <name> <mfa-code>"
|
239
|
+
exit 1
|
145
240
|
end
|
146
241
|
|
242
|
+
role_key = get_item("#{item_name} role-key")
|
243
|
+
role_token = get_item("#{item_name} role-token")
|
244
|
+
delete_pair(role_key, role_token, '# Removing STS role credentials')
|
245
|
+
|
147
246
|
sts_item = get_item("#{item_name} mfa")
|
148
247
|
sts_token = get_item("#{item_name} token")
|
149
|
-
|
150
|
-
puts "Removing existing STS credentials"
|
151
|
-
sts_item.delete
|
152
|
-
sts_token.delete if sts_token
|
153
|
-
end
|
248
|
+
delete_pair(sts_item, sts_token, '# Removing STS credentials')
|
154
249
|
|
155
250
|
item, token = get_item(item_name)
|
156
|
-
sts =
|
251
|
+
sts = Aws::STS::Client.new(access_key_id: item.attributes[:account],
|
252
|
+
secret_access_key: item.password)
|
157
253
|
begin
|
158
|
-
response = sts.
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
254
|
+
response = sts.get_session_token(duration_seconds: (60 * 60 * 12),
|
255
|
+
serial_number: item.attributes[:comment],
|
256
|
+
token_code: code)
|
257
|
+
keychain.generic_passwords.create(label: "#{item_name} mfa",
|
258
|
+
account: response.credentials[:access_key_id],
|
259
|
+
password: response.credentials[:secret_access_key],
|
260
|
+
comment: response.credentials[:expiration].to_i.to_s)
|
261
|
+
keychain.generic_passwords.create(label: "#{item_name} token",
|
262
|
+
account: "#{response.credentials[:access_key_id]}_token",
|
263
|
+
password: response.credentials[:session_token],
|
264
|
+
comment: "#{item_name} mfa")
|
265
|
+
|
266
|
+
puts "MultiFactorAuthentication succeeded, expiration is #{response.credentials[:expiration]}"
|
267
|
+
rescue Aws::STS::Errors::AccessDenied => e
|
170
268
|
puts e.to_s
|
171
269
|
end
|
172
270
|
|
173
271
|
when 'env'
|
174
|
-
item, token = get_item_from_args_for_command('
|
272
|
+
item, token = get_item_from_args_for_command('env')
|
175
273
|
key = item.password
|
176
274
|
puts "export AWS_ACCESS_KEY_ID=\"#{item.attributes[:account]}\""
|
177
275
|
puts "export AWS_ACCESS_KEY=\"#{item.attributes[:account]}\""
|
178
276
|
puts "export AWS_SECRET_ACCESS_KEY=\"#{key}\""
|
179
277
|
puts "export AWS_SECRET_KEY=\"#{key}\""
|
180
|
-
puts "export RPROMPT=\"(aws #{item.attributes[:label]})\""
|
181
|
-
puts "export AWS_CREDS_NAME=\"#{item.attributes[:label]}\""
|
182
278
|
if token
|
279
|
+
puts "export RPROMPT=\"(aws #{token.attributes[:comment]})\""
|
280
|
+
puts "export AWS_CREDS_NAME=\"#{token.attributes[:comment]}\""
|
183
281
|
puts "export AWS_SECURITY_TOKEN=\"#{token.password}\""
|
184
282
|
puts "export AWS_SESSION_TOKEN=\"#{token.password}\""
|
283
|
+
else
|
284
|
+
puts "export RPROMPT=\"(aws #{item.attributes[:label]})\""
|
285
|
+
puts "export AWS_CREDS_NAME=\"#{item.attributes[:label]}\""
|
286
|
+
puts 'unset AWS_SECURITY_TOKEN'
|
287
|
+
puts 'unset AWS_SESSION_TOKEN'
|
185
288
|
end
|
186
289
|
|
187
290
|
when 'shell'
|
@@ -196,13 +299,16 @@ when 'shell'
|
|
196
299
|
aws_env = {}
|
197
300
|
aws_env['AWS_ACCESS_KEY_ID'] = aws_env['AWS_ACCESS_KEY'] = item.attributes[:account]
|
198
301
|
aws_env['AWS_SECRET_ACCESS_KEY'] = aws_env['AWS_SECRET_KEY'] = item.password
|
199
|
-
aws_env['AWS_CREDS_NAME'] = item.attributes[:label]
|
200
302
|
if token
|
303
|
+
aws_env['AWS_CREDS_NAME'] = token.attributes[:comment]
|
201
304
|
aws_env['AWS_SECURITY_TOKEN'] = aws_env['AWS_SESSION_TOKEN'] = token.password
|
305
|
+
else
|
306
|
+
aws_env['AWS_CREDS_NAME'] = item.attributes[:label]
|
202
307
|
end
|
203
308
|
|
204
309
|
if ARGV.empty?
|
205
310
|
aws_env['RPROMPT'] = "(aws #{item.attributes[:label]})" # zsh only
|
311
|
+
|
206
312
|
if prefs['shell_arguments']
|
207
313
|
exec(aws_env, ENV['SHELL'], prefs['shell_arguments'])
|
208
314
|
else
|
@@ -213,6 +319,6 @@ when 'shell'
|
|
213
319
|
end
|
214
320
|
|
215
321
|
else
|
216
|
-
puts "Usage: #{$
|
217
|
-
puts
|
322
|
+
puts "Usage: #{$PROGRAM_NAME} <command> <arguments>"
|
323
|
+
puts ' Commands: init, ls, add, add-role, assume-role, cat, env, mfa, rm, shell'
|
218
324
|
end
|
@@ -3,23 +3,21 @@ require 'keychain'
|
|
3
3
|
require 'aws-keychain-util'
|
4
4
|
|
5
5
|
module AwsKeychainUtil
|
6
|
+
# class to automatically grab AWS credentials from your keychain
|
6
7
|
class CredentialProvider
|
7
|
-
include
|
8
|
+
include Aws::CredentialProvider
|
8
9
|
|
9
10
|
attr_reader :item, :keychain
|
10
11
|
|
11
12
|
def initialize(item = 'AWS', keychain = nil)
|
12
|
-
@item
|
13
|
+
@item = item
|
14
|
+
@keychain = keychain
|
13
15
|
end
|
14
16
|
|
15
|
-
def
|
17
|
+
def credentials
|
16
18
|
keychain = @keychain ? Keychain.open(@keychain) : AwsKeychainUtil.load_keychain
|
17
|
-
item = keychain.generic_passwords.where(:
|
18
|
-
|
19
|
-
{
|
20
|
-
access_key_id: item.attributes[:account],
|
21
|
-
secret_access_key: item.password
|
22
|
-
}
|
19
|
+
item = keychain.generic_passwords.where(label: @item).first
|
20
|
+
Aws::Credentials.new(item.attributes[:account], item.password)
|
23
21
|
end
|
24
22
|
end
|
25
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-keychain-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Wily
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-keychain
|
@@ -39,13 +39,41 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: aws-sdk
|
42
|
+
name: aws-sdk
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
|
-
type: :
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
@@ -61,14 +89,15 @@ extensions: []
|
|
61
89
|
extra_rdoc_files: []
|
62
90
|
files:
|
63
91
|
- ".gitignore"
|
92
|
+
- ".rubocop.yml"
|
64
93
|
- Gemfile
|
65
94
|
- LICENSE.txt
|
66
95
|
- README.md
|
67
96
|
- Rakefile
|
68
97
|
- aws-keychain-util.gemspec
|
69
98
|
- bin/aws-creds
|
70
|
-
- lib/aws-keychain-util.rb
|
71
99
|
- lib/aws-keychain-util/credential_provider.rb
|
100
|
+
- lib/aws_keychain_util.rb
|
72
101
|
homepage: ''
|
73
102
|
licenses: []
|
74
103
|
metadata: {}
|
@@ -93,4 +122,3 @@ signing_key:
|
|
93
122
|
specification_version: 4
|
94
123
|
summary: Helps manage a keychain of AWS credentials on OS X.
|
95
124
|
test_files: []
|
96
|
-
has_rdoc:
|