aws_assume_role 1.1.0-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rubocop.yml +57 -0
  4. data/.ruby-version +1 -0
  5. data/.simplecov +22 -0
  6. data/.travis.yml +24 -0
  7. data/CHANGELOG.md +61 -0
  8. data/Gemfile +18 -0
  9. data/LICENSE.md +201 -0
  10. data/README.md +303 -0
  11. data/Rakefile +63 -0
  12. data/aws_assume_role.gemspec +56 -0
  13. data/bin/aws-assume-role +4 -0
  14. data/i18n/en.yml +109 -0
  15. data/lib/aws_assume_role.rb +4 -0
  16. data/lib/aws_assume_role/cli.rb +20 -0
  17. data/lib/aws_assume_role/cli/actions/abstract_action.rb +61 -0
  18. data/lib/aws_assume_role/cli/actions/configure_profile.rb +24 -0
  19. data/lib/aws_assume_role/cli/actions/configure_role_assumption.rb +22 -0
  20. data/lib/aws_assume_role/cli/actions/console.rb +70 -0
  21. data/lib/aws_assume_role/cli/actions/delete_profile.rb +22 -0
  22. data/lib/aws_assume_role/cli/actions/includes.rb +12 -0
  23. data/lib/aws_assume_role/cli/actions/list_profiles.rb +12 -0
  24. data/lib/aws_assume_role/cli/actions/migrate_profile.rb +20 -0
  25. data/lib/aws_assume_role/cli/actions/reset_environment.rb +50 -0
  26. data/lib/aws_assume_role/cli/actions/run.rb +36 -0
  27. data/lib/aws_assume_role/cli/actions/set_environment.rb +62 -0
  28. data/lib/aws_assume_role/cli/actions/test.rb +35 -0
  29. data/lib/aws_assume_role/cli/commands/configure.rb +32 -0
  30. data/lib/aws_assume_role/cli/commands/console.rb +19 -0
  31. data/lib/aws_assume_role/cli/commands/delete.rb +13 -0
  32. data/lib/aws_assume_role/cli/commands/environment.rb +34 -0
  33. data/lib/aws_assume_role/cli/commands/list.rb +12 -0
  34. data/lib/aws_assume_role/cli/commands/migrate.rb +13 -0
  35. data/lib/aws_assume_role/cli/commands/run.rb +19 -0
  36. data/lib/aws_assume_role/cli/commands/test.rb +20 -0
  37. data/lib/aws_assume_role/cli/includes.rb +3 -0
  38. data/lib/aws_assume_role/configuration.rb +30 -0
  39. data/lib/aws_assume_role/core_ext/aws-sdk/credential_provider_chain.rb +4 -0
  40. data/lib/aws_assume_role/core_ext/aws-sdk/includes.rb +9 -0
  41. data/lib/aws_assume_role/credentials/factories.rb +11 -0
  42. data/lib/aws_assume_role/credentials/factories/abstract_factory.rb +33 -0
  43. data/lib/aws_assume_role/credentials/factories/assume_role.rb +39 -0
  44. data/lib/aws_assume_role/credentials/factories/default_chain_provider.rb +113 -0
  45. data/lib/aws_assume_role/credentials/factories/environment.rb +26 -0
  46. data/lib/aws_assume_role/credentials/factories/includes.rb +15 -0
  47. data/lib/aws_assume_role/credentials/factories/instance_profile.rb +19 -0
  48. data/lib/aws_assume_role/credentials/factories/repository.rb +37 -0
  49. data/lib/aws_assume_role/credentials/factories/shared.rb +19 -0
  50. data/lib/aws_assume_role/credentials/factories/static.rb +18 -0
  51. data/lib/aws_assume_role/credentials/includes.rb +6 -0
  52. data/lib/aws_assume_role/credentials/providers/assume_role_credentials.rb +60 -0
  53. data/lib/aws_assume_role/credentials/providers/includes.rb +9 -0
  54. data/lib/aws_assume_role/credentials/providers/mfa_session_credentials.rb +119 -0
  55. data/lib/aws_assume_role/credentials/providers/shared_keyring_credentials.rb +41 -0
  56. data/lib/aws_assume_role/includes.rb +38 -0
  57. data/lib/aws_assume_role/logging.rb +27 -0
  58. data/lib/aws_assume_role/profile_configuration.rb +73 -0
  59. data/lib/aws_assume_role/runner.rb +40 -0
  60. data/lib/aws_assume_role/store/includes.rb +8 -0
  61. data/lib/aws_assume_role/store/keyring.rb +61 -0
  62. data/lib/aws_assume_role/store/serialization.rb +20 -0
  63. data/lib/aws_assume_role/store/shared_config_with_keyring.rb +250 -0
  64. data/lib/aws_assume_role/types.rb +31 -0
  65. data/lib/aws_assume_role/ui.rb +57 -0
  66. data/lib/aws_assume_role/vendored/aws.rb +4 -0
  67. data/lib/aws_assume_role/vendored/aws/README.md +2 -0
  68. data/lib/aws_assume_role/vendored/aws/assume_role_credentials.rb +67 -0
  69. data/lib/aws_assume_role/vendored/aws/includes.rb +9 -0
  70. data/lib/aws_assume_role/vendored/aws/refreshing_credentials.rb +58 -0
  71. data/lib/aws_assume_role/vendored/aws/shared_config.rb +223 -0
  72. data/lib/aws_assume_role/version.rb +5 -0
  73. metadata +438 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 80766e274bca0bd30c54400247e55717a9fa5c1899d67cf9c08158324c457e9c
4
+ data.tar.gz: 9efd6ebbb0d4d9517bb08ff99a0268ead47934f524f5824b4584696ce55bbdd2
5
+ SHA512:
6
+ metadata.gz: 1d301c8414767965d80c0cc97b123107d8f6661f3b7ac725b5c2d5b4ca3fc76c7d8a44b742c293ecc4a8acc90bff2998b5725d5d7f7b6e2e08b4f6a2f5a8ab55
7
+ data.tar.gz: 36d28bf31fe195de8696b8c4ada51c3e7c47528f26969146f4ceb448685cae6bed437f6688f989811ed526ace45cfb484b0f736224ae6266ad1aec977797838e
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ .bundle/
2
+ *.swp
3
+ vendor/
4
+ pkg/
5
+ Gemfile.lock
6
+ spec/reports/
7
+ tags
8
+ *.gem
9
+ coverage
data/.rubocop.yml ADDED
@@ -0,0 +1,57 @@
1
+ ---
2
+ AllCops:
3
+ TargetRubyVersion: 2.2
4
+ DisplayCopNames: true
5
+ Exclude:
6
+ - 'lib/aws_assume_role/vendored/**/*.rb'
7
+
8
+ Metrics/MethodLength:
9
+ Enabled: false
10
+
11
+ Metrics/AbcSize:
12
+ Enabled: false
13
+
14
+ Metrics/BlockLength:
15
+ Enabled: false
16
+
17
+ Metrics/ClassLength:
18
+ Enabled: false
19
+
20
+ Metrics/CyclomaticComplexity:
21
+ Enabled: false
22
+
23
+ Metrics/PerceivedComplexity:
24
+ Enabled: false
25
+
26
+ Layout/IndentationWidth:
27
+ Width: 4
28
+
29
+ Layout/IndentHeredoc:
30
+ Enabled: false
31
+
32
+ Style/TrailingCommaInArguments:
33
+ EnforcedStyleForMultiline: comma
34
+
35
+ Style/TrailingCommaInLiteral:
36
+ EnforcedStyleForMultiline: comma
37
+
38
+ Style/ClassAndModuleChildren:
39
+ Enabled: false
40
+
41
+ Style/Documentation:
42
+ Enabled: false
43
+
44
+ Naming/VariableName:
45
+ Enabled: false
46
+
47
+ Style/StringLiterals:
48
+ EnforcedStyle: double_quotes
49
+
50
+ Style/MethodMissing:
51
+ Enabled: false
52
+
53
+ Style/TrivialAccessors:
54
+ Enabled: false
55
+
56
+ Metrics/LineLength:
57
+ Max: 140
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.5
data/.simplecov ADDED
@@ -0,0 +1,22 @@
1
+ require 'coveralls'
2
+ Coveralls.wear_merged!
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter
7
+ ])
8
+
9
+ SimpleCov.start do
10
+
11
+ project_name 'AWS Assume Role'
12
+
13
+ add_filter '/spec/'
14
+ add_filter 'lib/aws_assume_role/vendored'
15
+
16
+ %w(aws_assume_role).each do |group_name|
17
+ add_group(group_name, "/#{group_name}/lib")
18
+ end
19
+
20
+ merge_timeout 60 * 15 # 15 minutes
21
+
22
+ end
data/.travis.yml ADDED
@@ -0,0 +1,24 @@
1
+ language: ruby
2
+ sudo: false
3
+ script: bundle exec rake
4
+ jobs:
5
+ include:
6
+ - stage: test
7
+ rvm: 2.2
8
+ script: bundle exec rake
9
+ - rvm: 2.3
10
+ script: bundle exec rake
11
+ - stage: deploy
12
+ rvm: 2.3
13
+ script: bundle exec rake setup_credentials && chmod 0600 /home/travis/.gem/credentials && bundle exec rake publish
14
+ secure: "VQtFNu/kHZdKrmURVx4cPgW4uo+7klWQkMA9fJVYvyQzYoELmo/Q5L/75AE8mzNzXHTsRfRu/ggA5vlyHtXpQguz0Tz/pZ0pi24HKIkFFYzmXL4xb2depLTLu2DBFOZUPhshyIEJ9rVhT4sE2E7TOZErhJ1od5NQFAn1I17NyF3qStiORpjptSeU12OReNrlx0kquiZjyYklxO1M3ybzWHLmxVYNRjabqjkm0YB2NrTTFraeivixpRLSolsbzxRBxZwT7UOv/zbEcp9RGZDHxtxcD71rq8KaCXWzscErrcCiJtzrnHUHjAULFFkCPD+rCSbJJkydjxFjg3lVJbf5JulZYr4VzWLimjLUZv4HeeN+bvtwrPKCOe0KxRnsAr4kieX16MO/5ehkNHzjFyiSfkVGWK0uoWGNE9MdCwHLo+o+cz3XoKMQFZhmSheuxKKibr0m9PedynQQdg7bc3kB3UaYurrDs5ldb8e97BnZJrTaTD3/8vaWv30MFuZ+Nw/Hi2uEP7nIZoZfz2D8S6a83YLAC7YAfnf/1lMCU2mfBSLg6L8H26h5bmOUfg10ZNiJDW0g0WqbjbI0xUcMjHd5qdPYP1bH4qtXAdDp9I09NHpteEo42P58milj7n7qWAx+TiRnQR0/jBJL+dXGwYRfoXuzI+4QDy8sq20Cvi34RPU="
15
+
16
+ stages:
17
+ - name: test
18
+ - name: deploy
19
+ if: tag =~ ^v
20
+ notifications:
21
+ slack:
22
+ secure: RmJmJSSDI8qdIpM2KKYoXX2mpcL85YZ9r9gF4rauZH9TuqnYOPP3kQ5iYJsE0VUTuZpuvQ8Axoux5IQr+IDK7kMrmrI0iaZp1dAR9tGK+aLF73sprOmQEou6HIoDs97UQhOWlsAUR8max/7WYdJYJ1o78dqavfFtOy0VcHCkUMRf+WxcKzz+8MunsocIYi0HXuz5vC3RAZCOaK2h8epXzmnWq0ke8YeTmddpDWC85wzeDNjA9T1j5WD+y6gC9F0vyaqVqDCsCXlbRKZl7a1TU9QGDVyBzowoGsWmTpFR80v4CKofAn6nnMRqblwATOS1jMT+HC+Yku29qFzXPugYa2KAUSQaYQiOe+TE5IDa2Exe/57ZQCOq4ve8gKSE9aQXh4Riq3u8qccM+UeoQdcwgXQIciTeWjqi4LQro6Dbyrv8XrUbxdG0VPsWmf49jbWgq6PPAJqdcbXr9eGb+81uJ2REa1vhDYZu4T3JHv4erd5QlyYWzeBJ/LMQav/C5mnMF43jg8DzZ2g0BZBao/reO9xcZre/ka8eOus9Ll1i+8PCxmFZMx2KDPC9i5R7bXL/CwPBjzFInmvHM0cgKjxrRSY6xMWSPyBbgdsKJl2qag74K5xG+2VPlMcVx0ikTKVjsja5iPlOYKhflGAfCKvpzPcd2QoEWg8jZYqZtO9Nj+M=
23
+ on_success: change
24
+ on_failure: change
data/CHANGELOG.md ADDED
@@ -0,0 +1,61 @@
1
+ ## 1.1.0
2
+ * Publish separate gems for Linux, BSD and MacOS (@randomvariable)
3
+
4
+ ## 1.0.6
5
+ * Determine gem dependencies for OS X & Linux at install time (@randomvariable)
6
+
7
+ ## 1.0.5
8
+ * Escape run commands properly (@mrprimate)
9
+
10
+ ## 1.0.4
11
+ * Ensure ~/.aws exists before saving configuration
12
+
13
+ ## 1.0.3
14
+ * Fix setting environment variable throwing string frozen error (@timbirk)
15
+
16
+ ## 1.0.2
17
+ * Display credential prompts on stderr to allow shell eval to work (@timbirk)
18
+
19
+ ## 1.0.1
20
+ * Fix setting environment variable throwing string frozen error (@mrprimate)
21
+ * Fix incompatibility with version 0.4 of dry-struct (@tomhaynes)
22
+
23
+ ## 1.0.0
24
+ * Fix deprecation warnings for dry-types
25
+ * Minimum Ruby version is now 2.2
26
+
27
+ ## 0.2.2
28
+ * Add Yubikey OATH support to the default chain provider (@randomvariable)
29
+
30
+ ## 0.2.1
31
+ * Loosen requirement on highline to improve compatibility with Puppet tools (@randomvariable)
32
+
33
+ ## 0.2.0
34
+
35
+ * Add support for Yubikey as a source for MFA (@davbo)
36
+ * Remove expired credentials before writing new STS credentials (@davbo)
37
+
38
+ ## 0.1.2
39
+
40
+ * Become compatible with Ruby 2.1 (@randomvariable)
41
+ * Added test suite from AWS SDK for Ruby (@randomvariable)
42
+
43
+ ## 0.1.1
44
+
45
+ * Fix logging on Ruby 2.2 (@randomvariable)
46
+
47
+ ## 0.1.0
48
+
49
+ * Complete rewrite with SDK compatible API layer (@randomvariable)
50
+
51
+ ## 0.0.3
52
+
53
+ * Store master credentials in OS credential store. (@mrprimate)
54
+
55
+ ## 0.0.2
56
+
57
+ * Add CLI (@mrprimate)
58
+
59
+ ## 0.0.1
60
+
61
+ * Initial release (@jtopper)
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ group :test do
8
+ gem "coveralls", require: false
9
+ gem "rake"
10
+ end
11
+
12
+ group :development do
13
+ gem "pry", "~> 0.10"
14
+ gem "pry-byebug"
15
+ gem "pry-rescue", "~> 1.4"
16
+ gem "pry-stack_explorer", "~> 0.4"
17
+ gem "pry-state"
18
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,303 @@
1
+ aws-assume-role
2
+ ---------------
3
+ [![Build Status](https://travis-ci.org/scalefactory/aws-assume-role.svg?branch=master)](https://travis-ci.org/scalefactory/aws-assume-role)
4
+ [![Coverage Status](https://coveralls.io/repos/github/scalefactory/aws-assume-role/badge.svg?branch=master)](https://coveralls.io/github/scalefactory/aws-assume-role?branch=master)
5
+ [![Code Climate](https://codeclimate.com/github/scalefactory/aws-assume-role/badges/gpa.svg)](https://codeclimate.com/github/scalefactory/aws-assume-role)
6
+ [![Gem Version](https://badge.fury.io/rb/aws_assume_role.svg)](https://badge.fury.io/rb/aws_assume_role)
7
+
8
+ aws-assume-role is a utility intended for developer and operator environments
9
+ who need to use 2FA and role assumption to access AWS services.
10
+
11
+ aws-assume-role can store both AWS access keys and ephemeral session tokens in
12
+ OS credential vaults - Keychain on OSX and Keyring on Gnome.
13
+
14
+ Why?
15
+ ---
16
+
17
+ This keeps your credentials safe in the keystore, and exist as
18
+ environment variables for the duration and context of the executing command.
19
+ This helps prevent credential leaking and theft, and means they aren't stored on
20
+ disk as unencrypted files.
21
+
22
+ It allows easy credential management and role assumption with a 2FA/MFA device.
23
+
24
+ For more information on role assumption, see the [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html).
25
+
26
+ Requirements
27
+ ------------
28
+ * Ruby ≥ 2.2
29
+ * macOS Keychain / GNOME Keyring
30
+ * At least one account with Amazon Web Services
31
+ * An IAM role configured in the target account
32
+ * An IAM user with rights to assume that role
33
+
34
+ Install
35
+ -------
36
+
37
+ ```sh
38
+ gem install aws_assume_role
39
+ ```
40
+
41
+ ### Platform notes
42
+
43
+ Gnome Keyring uses the [GirFFI](https://github.com/mvz/gir_ffi) bindings, which
44
+ require introspection bindings as well as Gnone Keyring, by installing one of the following packages:
45
+
46
+ ``` sh
47
+ # Debian/Ubuntu
48
+ apt-get install gnome-keyring libgirepository1.0-dev libgnome-keyring-common libgnome-keyring-dev
49
+
50
+ # Fedora
51
+ dnf install gobject-introspection-devel
52
+
53
+ # CentOS
54
+ yum install gobject-introspection-devel
55
+ ```
56
+ Setup
57
+ -----
58
+
59
+ You should already have an IAM user that you can log in to via AWS' console.
60
+ If you do not already have an AWS access key and matching secret key for your
61
+ own IAM user, use the AWS console to create that credential pair.
62
+
63
+ aws-assume-role works best if you also store permanent credentials in your keystore:
64
+
65
+ ``` sh
66
+ > aws-assume-role configure
67
+ Enter the profile name to save into configuration
68
+ company_sso
69
+ Enter the AWS region you would like to default to:
70
+ eu-west-1
71
+ Enter the AWS Access Key ID to use for this profile:
72
+ 1234567890010
73
+ Enter the AWS Secret Access Key to use for this profile:
74
+ abcdefghijklmnopqrstuvwzyx1
75
+ Profile `company_sso` saved to '/home/growthsmith/.aws/config'
76
+ ```
77
+
78
+ ### Configuring roles
79
+ Now that you've set up permanent credentials in your OS credential store, you can now
80
+ set up a role that you will assume in every day use:
81
+
82
+ ``` sh
83
+ > aws-assume-role configure role -p company-dev --source-profile company_sso \
84
+ --role-arn=arn:aws:iam::000000000001:role/ViewEC2 --role-session-name=growthsmith \
85
+ --mfa-serial automatic
86
+ ```
87
+ `--mfa-serial automatic` will look up your default attached multi-factor device, but you can specify a specific ARN.
88
+
89
+ More options are available in the application help.
90
+ Use `> aws-assume-role --help ` for help at any time.
91
+
92
+ Using MFA TOTP with a Yubikey
93
+ -----------------------------
94
+
95
+ [Yubikeys support TOTP](https://developers.yubico.com/OATH/) this offers some
96
+ benefits over using a phone. One benefit is the TOTP token can be retrieved by
97
+ an API call rather than a user reading the token from the device.
98
+
99
+ This allows developers to call AWS through aws-assume-role, providing an MFA
100
+ token without prompting for user input. To use this specify
101
+ `--yubikey-oath-name` when calling configure role.
102
+
103
+ ``` sh
104
+ > aws-assume-role configure role -p company-dev --source-profile company_sso \
105
+ --role-arn=arn:aws:iam::000000000001:role/ViewEC2 --role-session-name=growthsmith \
106
+ --mfa-serial automatic --yubikey-oath-name "Amazon Web Services:myuser@company_sso"
107
+ ```
108
+
109
+ _Yubikey Support_: `aws-assume-role` uses the [smartcard gem](https://rubygems.org/gems/smartcard)
110
+ to connect to the Yubikey, this itself depends upon some C libraries being installed. They provide
111
+ [platform specific instructions](https://github.com/costan/smartcard/blob/master/BUILD#L19)
112
+ for installing these libraries PC/SC.
113
+
114
+ Testing a profile
115
+ -----------------
116
+ You can test a profile using
117
+ ```sh
118
+ > aws-assume-role test -p company_sso
119
+ Logged in as:
120
+ User: 9999999999
121
+ Account: arn:aws:iam::3333333333:user/username
122
+ ARN: AIDAIOSWINGTB
123
+
124
+ ```
125
+
126
+ Running applications
127
+ --------------------
128
+
129
+ You can run another application using
130
+
131
+ ``` sh
132
+ aws-assume-role run -p company-dev -- aws ec2 describe-instances --query \
133
+ "Reservations[*].Instances[*].PrivateIpAddress" --output=text
134
+ 10.254.4.20
135
+ 10.254.4.15
136
+ 10.254.0.10
137
+ 10.254.4.5
138
+ ```
139
+
140
+ Because we've enabled MFA, aws-assume-role will ask for your MFA token:
141
+ ```
142
+ Please provide an MFA token
143
+ 000000
144
+ ```
145
+
146
+ Listing available profiles
147
+ --------------------------
148
+ Configured profiles can be listed:
149
+ ```sh
150
+ > aws-assume-role list
151
+ company_sso
152
+ company2_sso
153
+ company3_sso
154
+ ```
155
+
156
+ Deleting a profile
157
+ ------------------
158
+ If a set of credentials key needs revoking, or the profile isn't relevant anymore:
159
+ ``` sh
160
+ > aws-assume-role delete -p company_sso
161
+ Please type the name of the profile, i.e. company_sso , to continue deletion.
162
+ company_sso
163
+ Profile company_sso deleted
164
+ ```
165
+
166
+ Migrating AWS CLI profiles
167
+ ------------------
168
+ It's better to revoke the existing keys and generate new ones. We try to overwrite the plaintext configuration
169
+ file with random data, but this does not take care of ~/.aws/credentials and does not account for SSD wear
170
+ levelling or copy-on-write snapshots.
171
+ ```
172
+ aws-assume-role migrate -p company_sso
173
+ Profile 'company_sso' migrated to keyring.
174
+ ```
175
+
176
+ Exporting environment variables
177
+ -------------------------------
178
+ You can use a session token in your shell any supported application without using
179
+ `aws-assume-role`.
180
+
181
+ You can also remove environment variables after finishing using the reset command.
182
+
183
+ #### Bourne Shell and friends
184
+ ``` sh
185
+ > eval `./bin/aws-assume-role environment set -p company-dev`
186
+ > eval `./bin/aws-assume-role environment reset`
187
+ ```
188
+
189
+ #### fish
190
+ ``` fish
191
+ > set creds (bin/aws-assume-role environment set -s fish -p company-dev); eval $creds; set -e creds
192
+ > set creds (bin/aws-assume-role environment reset -s fish); eval $creds; set -e creds
193
+ ```
194
+
195
+ #### PowerShell
196
+ ``` powershell
197
+ > aws-assume-role environment set -s powershell -p company-dev | invoke-expression
198
+ > aws-assume-role environment reset -s powershell | invoke-expression
199
+ ```
200
+
201
+ Launch the AWS console
202
+ ---------------------
203
+ Given that `aws-assume-role` has knowledge of your role ARNs via AWS CLI profiles, you can
204
+ get to the AWS console for that role/account using
205
+
206
+ ``` sh
207
+ > aws-assume-role console -p company_sso
208
+ ```
209
+
210
+ `aws-assume-role` will first attempt to log in and get a federated UI link, and
211
+ otherwise fall back to the "switch role" page.
212
+
213
+ Using inside Ruby
214
+ -----------------
215
+ To get a set of credentials via the OS credential store, or using console-based MFA, use
216
+ the following:
217
+ ```
218
+ require "aws_assume_role"
219
+
220
+ AwsAssumeRole::DefaultProvider.new(options).resolve
221
+ ```
222
+ where options is a hash with the following symbol keys:
223
+ * `access_key_id`
224
+ * `secret_access_key`
225
+ * `session_token`
226
+ * `persist_session`
227
+ * `duration_seconds`
228
+ * `role_arn`
229
+ * `role_session_name`
230
+ * `serial_number`
231
+ * `source_profile`
232
+ * `region`
233
+
234
+ `aws_assume_role` resolves credentials in almost the same way as the AWS SDK, i.e.:
235
+
236
+ ```no-highlight
237
+ static credentials ⟶ environment variables ⟶ configured profiles role ⟶ assumption (look up source profile and check for 2FA)
238
+ ```
239
+
240
+ Any of the above may get chained to do MFA or role assumption, or both,
241
+ in the following order:
242
+
243
+ ```no-highlight
244
+ second factor ⟶ ecs/instance profile
245
+ ```
246
+
247
+ These are the same as the AWS SDK equivalents whereever possible. The command line help will give an explanation of the rest.
248
+
249
+ ### Monkeypatching the AWS SDK
250
+ You can also override the standard AWS SDK credential resolution system by including the following:
251
+ ```
252
+ require "aws_assume_role/core_ext/aws-sdk/credential_provider_chain"
253
+ ```
254
+
255
+ Using any standard AWS SDK for Ruby v2 client will then use aws_assume_role for credential resolution.
256
+
257
+
258
+ Please do not use this in production systems.
259
+
260
+ Other keyring backends
261
+ ----------------------
262
+ `aws-assume-role` uses the Keyring gem for secure secret storage. By default, this will use OS X keycain
263
+ or GNOME Keyring. To load alternatives, set the following environment variables:
264
+
265
+ * `AWS_ASSUME_ROLE_KEYRING_BACKEND`: Which backend to use, as the name of the Ruby class.
266
+ * `AWS_ASSUME_ROLE_KEYRING_PLUGIN` : Name of a gem to load.
267
+
268
+ These are also available in Ruby as the `AwsAssumeRole.Config.backend_plugin` and
269
+ `AwsAssumeRole.Config.backend_plugin` attributes.
270
+
271
+
272
+ Development
273
+ -----------
274
+
275
+ Tests are conducted by Travis.
276
+
277
+ You can run these locally using Rake:
278
+
279
+ ```shell
280
+ bundle exec rake test
281
+ ```
282
+
283
+ License
284
+ -------
285
+
286
+ This library and program is distributed under the
287
+ [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
288
+
289
+ ```no-highlight
290
+ Copyright 2017. The Scale Factory Ltd. All Rights Reserved.
291
+ Portions Copyright 2013. Amazon Web Services, Inc. All Rights Reserved.
292
+
293
+ licensed under the apache license, version 2.0 (the "license");
294
+ you may not use this file except in compliance with the license.
295
+ you may obtain a copy of the license at
296
+
297
+ http://www.apache.org/licenses/license-2.0
298
+
299
+ unless required by applicable law or agreed to in writing, software
300
+ distributed under the license is distributed on an "as is" basis,
301
+ without warranties or conditions of any kind, either express or implied.
302
+ see the license for the specific language governing permissions and
303
+ limitations under the license.