awskeyring 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 +4 -4
- data/.rubocop.yml +0 -7
- data/.travis.yml +3 -2
- data/CODE_OF_CONDUCT.md +54 -30
- data/README.md +19 -6
- data/awskeyring.gemspec +4 -4
- data/lib/awskeyring/version.rb +1 -1
- data/lib/awskeyring.rb +9 -11
- data/lib/awskeyring_command.rb +32 -32
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e7e03d81e3086c6acea16f7eb514d1d52066bb5
|
4
|
+
data.tar.gz: 7af0c1e501fd4f11e331f6abec07329c997e0a47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d067652302c5c5e43e4975c392f880d373f61ca989c644a7c2fd473bd42c0723cbfc2cd041cc12c73a3add31752155ed8dd8bf15f71beb429e1b10f84edd81a4
|
7
|
+
data.tar.gz: 8f3434517adcbdf5185c315b1f33ae250d08dd56cb74e18c7d28397a3dd828fb6ce4209c28d9d6104f0085f34bb29c4f80c47e70d358e9e4cf54857f67bfb80a
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,24 +1,41 @@
|
|
1
|
-
# Contributor Code of Conduct
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
2
|
|
3
|
-
|
4
|
-
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
-
contribute through reporting issues, posting feature requests, updating
|
6
|
-
documentation, submitting pull requests or patches, and other activities.
|
3
|
+
## Our Pledge
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
12
22
|
|
13
23
|
Examples of unacceptable behavior by participants include:
|
14
24
|
|
15
|
-
* The use of sexualized language or imagery
|
16
|
-
|
17
|
-
* Trolling
|
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
|
18
28
|
* Public or private harassment
|
19
|
-
* Publishing
|
20
|
-
|
21
|
-
* Other
|
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.
|
22
39
|
|
23
40
|
Project maintainers have the right and responsibility to remove, edit, or
|
24
41
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
@@ -26,24 +43,31 @@ that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
43
|
permanently any contributor for other behaviors that they deem inappropriate,
|
27
44
|
threatening, offensive, or harmful.
|
28
45
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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.
|
33
54
|
|
34
|
-
|
35
|
-
when an individual is representing the project or its community.
|
55
|
+
## Enforcement
|
36
56
|
|
37
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
-
reported by contacting
|
58
|
+
reported by contacting the project team at [tristan@vibrato.com.au]. All
|
39
59
|
complaints will be reviewed and investigated and will result in a response that
|
40
|
-
is deemed necessary and appropriate to the circumstances.
|
41
|
-
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
-
|
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
|
43
69
|
|
44
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
-
version
|
46
|
-
[http://contributor-covenant.org/version/1/3/0/][version]
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
47
72
|
|
48
|
-
[homepage]:
|
49
|
-
[version]: http://contributor-covenant.org/version/1/3/0/
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
data/README.md
CHANGED
@@ -1,7 +1,21 @@
|
|
1
1
|
# Awskeyring
|
2
2
|
|
3
|
+
* [![Build Status](https://travis-ci.org/vibrato/awskeyring.svg?branch=master)](https://travis-ci.org/vibrato/awskeyring)
|
4
|
+
* [![Gem Version](https://badge.fury.io/rb/awskeyring.svg)](https://badge.fury.io/rb/awskeyring)
|
5
|
+
* [![license MIT](http://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
|
6
|
+
* [![All Downloads](http://ruby-gem-downloads-badge.herokuapp.com/awskeyring?type=total)](https://rubygems.org/gems/awskeyring)
|
7
|
+
* [![Version Downloads](http://ruby-gem-downloads-badge.herokuapp.com/awskeyring?label=downloads-current-version)](https://rubygems.org/gems/awskeyring)
|
8
|
+
|
3
9
|
Awskeyring is a small tool to manage AWS account keys in the macOS Keychain.
|
4
10
|
|
11
|
+
## Motivation
|
12
|
+
|
13
|
+
The motivation of this application is to provide a local secure store of AWS
|
14
|
+
credentials using specifically in the macOS Keychain, to have them easily accessed
|
15
|
+
from the Terminal, and to provide useful functions like assuming roles.
|
16
|
+
For Enterprise environments there are better suited tools to use
|
17
|
+
like [HashiCorp Vault](https://vaultproject.io/).
|
18
|
+
|
5
19
|
## Installation
|
6
20
|
|
7
21
|
Install it with:
|
@@ -10,7 +24,7 @@ Install it with:
|
|
10
24
|
|
11
25
|
## Usage
|
12
26
|
|
13
|
-
The CLI is using [Thor](http://whatisthor.com) with help provided
|
27
|
+
The CLI is using [Thor](http://whatisthor.com) with help provided interactively.
|
14
28
|
|
15
29
|
Commands:
|
16
30
|
awskeyring --version, -v # Prints the version
|
@@ -28,22 +42,21 @@ The CLI is using [Thor](http://whatisthor.com) with help provided interactivly.
|
|
28
42
|
|
29
43
|
and autocomplete that can be installed with:
|
30
44
|
|
31
|
-
$ complete -C /usr/local/bin/
|
45
|
+
$ complete -C /usr/local/bin/awskeyring awskeyring
|
32
46
|
|
33
|
-
To set your environment easily the following function helps:
|
47
|
+
To set your environment easily the following bash function helps:
|
34
48
|
|
35
49
|
awsenv() { eval "$(awskeyring env $1)"; }
|
36
50
|
|
37
51
|
## Development
|
38
52
|
|
39
|
-
After checking out the repo, run `
|
53
|
+
After checking out the repo, run `bundle update` to install dependencies. Then, run `rake` to run the tests. Run `bundle exec awskeyring` to use the gem in this directory, ignoring other installed copies of this gem.
|
40
54
|
|
41
55
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
42
56
|
|
43
57
|
## Contributing
|
44
58
|
|
45
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
46
|
-
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/vibrato/awskeyring. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
47
60
|
|
48
61
|
## License
|
49
62
|
|
data/awskeyring.gemspec
CHANGED
@@ -6,11 +6,11 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = 'awskeyring'
|
7
7
|
spec.version = Awskeyring::VERSION
|
8
8
|
spec.authors = ['Tristan Morgan']
|
9
|
-
spec.email = ['
|
9
|
+
spec.email = ['tristan@vibrato.com.au']
|
10
10
|
|
11
|
-
spec.summary = 'Manages AWS credentials in the
|
12
|
-
spec.description = 'Manages AWS credentials in the
|
13
|
-
spec.homepage = 'https://github.com/
|
11
|
+
spec.summary = 'Manages AWS credentials in the macOS keychain'
|
12
|
+
spec.description = 'Manages AWS credentials in the macOS keychain'
|
13
|
+
spec.homepage = 'https://github.com/vibrato/awskeyring'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
data/lib/awskeyring/version.rb
CHANGED
data/lib/awskeyring.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'keychain'
|
2
2
|
require 'aws-sdk-iam'
|
3
3
|
|
4
|
-
require 'awskeyring/version'
|
5
|
-
|
6
4
|
# Aws Key-ring logical object,
|
7
5
|
# gives you an interface to access keychains and items.
|
8
6
|
module Awskeyring
|
@@ -76,15 +74,15 @@ module Awskeyring
|
|
76
74
|
)
|
77
75
|
end
|
78
76
|
|
79
|
-
def self.add_pair(
|
80
|
-
all_items.create(label: "session-key #{account}",
|
81
|
-
account: key,
|
82
|
-
password: secret,
|
83
|
-
comment: "#{ROLE_PREFIX}#{role}")
|
84
|
-
all_items.create(label: "session-token #{account}",
|
85
|
-
account: expiry,
|
86
|
-
password: token,
|
87
|
-
comment: "#{ROLE_PREFIX}#{role}")
|
77
|
+
def self.add_pair(params = {})
|
78
|
+
all_items.create(label: "session-key #{params[:account]}",
|
79
|
+
account: params[:key],
|
80
|
+
password: params[:secret],
|
81
|
+
comment: "#{ROLE_PREFIX}#{params[:role]}")
|
82
|
+
all_items.create(label: "session-token #{params[:account]}",
|
83
|
+
account: params[:expiry],
|
84
|
+
password: params[:token],
|
85
|
+
comment: "#{ROLE_PREFIX}#{params[:role]}")
|
88
86
|
end
|
89
87
|
|
90
88
|
def self.get_item(account)
|
data/lib/awskeyring_command.rb
CHANGED
@@ -6,9 +6,10 @@ require 'open-uri'
|
|
6
6
|
require 'thor'
|
7
7
|
|
8
8
|
require_relative 'awskeyring'
|
9
|
+
require 'awskeyring/version'
|
9
10
|
|
10
11
|
# AWS Key-ring command line interface.
|
11
|
-
class AwskeyringCommand < Thor
|
12
|
+
class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
|
12
13
|
map %w[--version -v] => :__version
|
13
14
|
map ['ls'] => :list
|
14
15
|
map ['lsr'] => :list_role
|
@@ -22,14 +23,13 @@ class AwskeyringCommand < Thor
|
|
22
23
|
|
23
24
|
desc 'initialise', 'Initialises a new KEYCHAIN'
|
24
25
|
method_option :keychain, type: :string, aliases: '-n', desc: 'Name of KEYCHAIN to initialise.'
|
25
|
-
def initialise
|
26
|
+
def initialise # rubocop:disable Metrics/AbcSize
|
26
27
|
unless Awskeyring.prefs.empty?
|
27
28
|
puts "#{Awskeyring::PREFS_FILE} exists. no need to initialise."
|
28
29
|
exit 1
|
29
30
|
end
|
30
31
|
|
31
|
-
keychain
|
32
|
-
keychain ||= ask(message: "Name for new keychain (default: 'awskeyring')")
|
32
|
+
keychain = ask_missing(existing: options[:keychain], message: "Name for new keychain (default: 'awskeyring')")
|
33
33
|
keychain = 'awskeyring' if keychain.empty?
|
34
34
|
|
35
35
|
puts 'Creating a new Keychain, you will be prompted for a password for it.'
|
@@ -55,7 +55,7 @@ class AwskeyringCommand < Thor
|
|
55
55
|
|
56
56
|
desc 'env ACCOUNT', 'Outputs bourne shell environment exports for an ACCOUNT'
|
57
57
|
def env(account = nil)
|
58
|
-
account
|
58
|
+
account = ask_missing(existing: account, message: 'account name')
|
59
59
|
cred, temp_cred = get_valid_item_pair(account: account)
|
60
60
|
token = temp_cred.password unless temp_cred.nil?
|
61
61
|
put_env_string(
|
@@ -71,13 +71,10 @@ class AwskeyringCommand < Thor
|
|
71
71
|
method_option :secret, type: :string, aliases: '-s', desc: 'AWS account secret.'
|
72
72
|
method_option :mfa, type: :string, aliases: '-m', desc: 'AWS virtual mfa arn.'
|
73
73
|
def add(account = nil)
|
74
|
-
account
|
75
|
-
key
|
76
|
-
|
77
|
-
|
78
|
-
secret ||= ask(message: 'secret access key', secure: true)
|
79
|
-
mfa ||= options[:mfa]
|
80
|
-
mfa ||= ask(message: 'mfa arn', optional: true)
|
74
|
+
account = ask_missing(existing: account, message: 'account name')
|
75
|
+
key = ask_missing(existing: options[:key], message: 'access key id')
|
76
|
+
secret = ask_missing(existing: options[:secret], message: 'secret access key', secure: true)
|
77
|
+
mfa = ask_missing(existing: options[:mfa], message: 'mfa arn', optional: true)
|
81
78
|
|
82
79
|
Awskeyring.add_item(
|
83
80
|
account: account,
|
@@ -91,10 +88,9 @@ class AwskeyringCommand < Thor
|
|
91
88
|
desc 'add-role ROLE', 'Adds a ROLE to the keyring'
|
92
89
|
method_option :arn, type: :string, aliases: '-a', desc: 'AWS role arn.'
|
93
90
|
def add_role(role = nil)
|
94
|
-
role
|
95
|
-
arn
|
96
|
-
|
97
|
-
account ||= ask(message: 'account', optional: true)
|
91
|
+
role = ask_missing(existing: role, message: 'role name')
|
92
|
+
arn = ask_missing(existing: options[:arn], message: 'role arn')
|
93
|
+
account = ask_missing(existing: account, message: 'account', optional: true)
|
98
94
|
|
99
95
|
Awskeyring.add_role(
|
100
96
|
role: role,
|
@@ -105,7 +101,7 @@ class AwskeyringCommand < Thor
|
|
105
101
|
|
106
102
|
desc 'remove ACCOUNT', 'Removes an ACCOUNT from the keyring'
|
107
103
|
def remove(account = nil)
|
108
|
-
account
|
104
|
+
account = ask_missing(existing: account, message: 'account name')
|
109
105
|
cred, temp_cred = get_valid_item_pair(account: account)
|
110
106
|
Awskeyring.delete_pair(cred, temp_cred, "# Removing account #{account}")
|
111
107
|
end
|
@@ -113,7 +109,7 @@ class AwskeyringCommand < Thor
|
|
113
109
|
map 'remove-role' => :remove_role
|
114
110
|
desc 'remove-role ROLE', 'Removes a ROLE from the keyring'
|
115
111
|
def remove_role(role = nil)
|
116
|
-
role
|
112
|
+
role = ask_missing(existing: role, message: 'role name')
|
117
113
|
item_role = Awskeyring.get_role(role)
|
118
114
|
Awskeyring.delete_pair(item_role, nil, "# Removing role #{role}")
|
119
115
|
end
|
@@ -122,8 +118,8 @@ class AwskeyringCommand < Thor
|
|
122
118
|
method_option :role, type: :string, aliases: '-r', desc: 'The ROLE to assume.'
|
123
119
|
method_option :code, type: :string, aliases: '-c', desc: 'Virtual mfa CODE.'
|
124
120
|
method_option :duration, type: :string, aliases: '-d', desc: 'Session DURATION in seconds.'
|
125
|
-
def token(account = nil, role = nil, code = nil)
|
126
|
-
account
|
121
|
+
def token(account = nil, role = nil, code = nil) # rubocop:disable all
|
122
|
+
account = ask_missing(existing: account, message: 'account name')
|
127
123
|
role ||= options[:role]
|
128
124
|
code ||= options[:code]
|
129
125
|
duration = options[:duration]
|
@@ -184,8 +180,8 @@ class AwskeyringCommand < Thor
|
|
184
180
|
end
|
185
181
|
|
186
182
|
desc 'console ACCOUNT', 'Open the AWS Console for the ACCOUNT'
|
187
|
-
def console(account = nil)
|
188
|
-
account
|
183
|
+
def console(account = nil) # rubocop:disable all
|
184
|
+
account = ask_missing(existing: account, message: 'account name')
|
189
185
|
cred, temp_cred = get_valid_item_pair(account: account)
|
190
186
|
token = temp_cred.password unless temp_cred.nil?
|
191
187
|
|
@@ -246,17 +242,19 @@ class AwskeyringCommand < Thor
|
|
246
242
|
comp_len = comp_line.split.length
|
247
243
|
comp_len += 1 if curr == ''
|
248
244
|
|
249
|
-
|
245
|
+
comp_len = 2 if prev == 'help'
|
246
|
+
comp_len = 4 if prev == 'remove-role'
|
247
|
+
print_auto_resp(curr, comp_len)
|
248
|
+
end
|
249
|
+
|
250
|
+
private
|
251
|
+
|
252
|
+
def print_auto_resp(curr, len) # rubocop:disable Metrics/AbcSize
|
253
|
+
case len
|
250
254
|
when 2
|
251
255
|
puts list_commands.select { |elem| elem.start_with?(curr) }.join("\n")
|
252
256
|
when 3
|
253
|
-
|
254
|
-
puts list_commands.select { |elem| elem.start_with?(curr) }.join("\n")
|
255
|
-
elsif prev == 'remove-role'
|
256
|
-
puts Awskeyring.list_role_names.select { |elem| elem.start_with?(curr) }.join("\n")
|
257
|
-
else
|
258
|
-
puts Awskeyring.list_item_names.select { |elem| elem.start_with?(curr) }.join("\n")
|
259
|
-
end
|
257
|
+
puts Awskeyring.list_item_names.select { |elem| elem.start_with?(curr) }.join("\n")
|
260
258
|
when 4
|
261
259
|
puts Awskeyring.list_role_names.select { |elem| elem.start_with?(curr) }.join("\n")
|
262
260
|
else
|
@@ -264,8 +262,6 @@ class AwskeyringCommand < Thor
|
|
264
262
|
end
|
265
263
|
end
|
266
264
|
|
267
|
-
private
|
268
|
-
|
269
265
|
def list_commands
|
270
266
|
self.class.all_commands.keys.map { |elem| elem.tr('_', '-') }
|
271
267
|
end
|
@@ -302,6 +298,10 @@ class AwskeyringCommand < Thor
|
|
302
298
|
end
|
303
299
|
end
|
304
300
|
|
301
|
+
def ask_missing(existing:, message:, secure: false, optional: false)
|
302
|
+
existing || ask(message: message, secure: secure, optional: optional)
|
303
|
+
end
|
304
|
+
|
305
305
|
def ask(message:, secure: false, optional: false)
|
306
306
|
if secure
|
307
307
|
HighLine.new.ask(message.rjust(20) + ': ') { |q| q.echo = '*' }
|
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.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tristan Morgan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-iam
|
@@ -122,9 +122,9 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
description: Manages AWS credentials in the
|
125
|
+
description: Manages AWS credentials in the macOS keychain
|
126
126
|
email:
|
127
|
-
-
|
127
|
+
- tristan@vibrato.com.au
|
128
128
|
executables:
|
129
129
|
- awskeyring
|
130
130
|
extensions: []
|
@@ -144,7 +144,7 @@ files:
|
|
144
144
|
- lib/awskeyring.rb
|
145
145
|
- lib/awskeyring/version.rb
|
146
146
|
- lib/awskeyring_command.rb
|
147
|
-
homepage: https://github.com/
|
147
|
+
homepage: https://github.com/vibrato/awskeyring
|
148
148
|
licenses:
|
149
149
|
- MIT
|
150
150
|
metadata: {}
|
@@ -167,5 +167,5 @@ rubyforge_project:
|
|
167
167
|
rubygems_version: 2.6.12
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
|
-
summary: Manages AWS credentials in the
|
170
|
+
summary: Manages AWS credentials in the macOS keychain
|
171
171
|
test_files: []
|