aws-mfa-secure 0.3.5 → 0.3.6

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: 94dd717cafaeea6c1d41e0e1ec7693af40f86f0f30f22aec621098d9fb1aa2ee
4
- data.tar.gz: 639c9af3947210e4d6ffe7b5c45ddb6d957da1bed71595291f66d16c27b4f545
3
+ metadata.gz: 7a728b3bca2a3ecf8c4566c122eeb29e98e8f2e54ce6bd515c601a0cd070933a
4
+ data.tar.gz: '00894d69954b1abba894fe5cbfbd71c360d33f87a3805413379634724e3da3cd'
5
5
  SHA512:
6
- metadata.gz: 9a35892f4b00e7b200beb44380ff4130bdba9d6777c7d06a5634bc2209c69ca8c418b8c74a42060aa8c47a5347ef493bd76ddd6512073cf5d64a87740a139cd4
7
- data.tar.gz: ec4e8369e2ace95feee53b7c1393cba411c6ca566f35db38aafbb06d30ca729002cbe37413c353ce3ba0e09a147abea24b9ddca425a84ece43da466827e860cc
6
+ metadata.gz: bfee9f00cb2b17c5123d6c57eaf5b078fff8b579b137900f27e9d8457bb22a8a737bbf2e597bbcefb845b986994f5678c2836ca3137c7fa11b82323feb9e9309
7
+ data.tar.gz: aa7ce5e4a34d622f877f16dba24687dc1d883c5b4f22db715528334df55e76fbb2dd1e0c82677ecbff98c72077097cd98a91555caac4f02ff2d4feef330516d1
@@ -3,6 +3,9 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.3.6]
7
+ - #1 speed up iam_mfa? detection with AWSConfig parser
8
+
6
9
  ## [0.3.5]
7
10
  - prompt for mfa when using AWS_* env and `AWS_MFA_SERIAL`
8
11
 
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # AWS MFA Secure
2
2
 
3
+ [![Watch the video](https://img.boltops.com/boltopspro/youtube/aws-mfa.png)](https://www.youtube.com/watch?v=cYqKeMUS9pc)
4
+
3
5
  [![Gem Version](https://badge.fury.io/rb/aws-mfa-secure.png)](http://badge.fury.io/rb/aws-mfa-secure)
4
6
 
5
7
  Surprisingly, the [aws cli](https://docs.aws.amazon.com/cli/latest/reference/) does not yet support MFA for normal IAM users. See: [boto/botocore/pull/1399](https://github.com/boto/botocore/pull/1399) The aws-mfa-secure tool decorates the AWS CLI or API to handle MFA authentication. The MFA prompt only activates if `mfa_serial` is configured.
@@ -11,7 +13,7 @@ Surprisingly, the [aws cli](https://docs.aws.amazon.com/cli/latest/reference/) d
11
13
  Prerequisite: The [AWS CLI](https://docs.aws.amazon.com/cli/latest/reference/) is required. You can install the AWS CLI via pip.
12
14
 
13
15
  pip install awscli --upgrade --user
14
-
16
+
15
17
  ## Usage
16
18
 
17
19
  **Summary**:
@@ -113,6 +115,13 @@ You can also set the MFA info with env variables. They take the highest preceden
113
115
 
114
116
  Docs: [How It Works](docs/how-it-works.md)
115
117
 
118
+ ## Linux Support
119
+
120
+ This tool only supports Linux. For Windows, you'll have to set the `AWS_*` env variables manually. Refer to these resources:
121
+
122
+ * [Switching to an IAM Role (Tools for Windows PowerShell)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-twp.html)
123
+ * [How do I use an MFA token to authenticate access to my AWS resources through the AWS CLI?](https://aws.amazon.com/premiumsupport/knowledge-center/authenticate-mfa-cli/)
124
+
116
125
  ## Related
117
126
 
118
127
  You may also be interested in [tongueroo/aws-rotate](https://github.com/tongueroo/aws-rotate). It's an easy way to rotate all your AWS keys in your `~/.aws/credentials`.
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency "activesupport"
22
22
  spec.add_dependency "aws-sdk-core"
23
+ spec.add_dependency "aws_config"
23
24
  spec.add_dependency "memoist"
24
25
  spec.add_dependency "rainbow"
25
26
  spec.add_dependency "thor"
@@ -1,4 +1,5 @@
1
1
  require "aws-sdk-core"
2
+ require "aws_config"
2
3
  require "json"
3
4
  require "memoist"
4
5
  require "time"
@@ -17,9 +18,9 @@ module AwsMfaSecure
17
18
  # The iam_mfa? check will only return true for the case when mfa_serial is set and access keys are used.
18
19
  # This is because for assume role cases, the current aws cli tool supports mfa_serial already.
19
20
  # Sending session AWS based access keys intefere with the current aws cli assume role mfa_serial support
20
- aws_access_key_id = aws_configure_get(:aws_access_key_id)
21
- aws_secret_access_key = aws_configure_get(:aws_secret_access_key)
22
- source_profile = aws_configure_get(:source_profile)
21
+ aws_access_key_id = aws_config(:aws_access_key_id)
22
+ aws_secret_access_key = aws_config(:aws_secret_access_key)
23
+ source_profile = aws_config(:source_profile)
23
24
 
24
25
  aws_access_key_id && aws_secret_access_key && !source_profile
25
26
  end
@@ -117,7 +118,7 @@ module AwsMfaSecure
117
118
  end
118
119
 
119
120
  def mfa_serial
120
- ENV['AWS_MFA_SERIAL'] || aws_configure_get(:mfa_serial)
121
+ ENV['AWS_MFA_SERIAL'] || aws_config(:mfa_serial)
121
122
  end
122
123
 
123
124
  def sts
@@ -125,13 +126,11 @@ module AwsMfaSecure
125
126
  end
126
127
  memoize :sts
127
128
 
128
- # Note the strip
129
- # Each aws configure get call has about a 300-400ms overhead so we memoize it.
130
- def aws_configure_get(prop)
131
- v = `aws configure get #{prop}`.strip
132
- v unless v.empty?
129
+ def aws_config(prop)
130
+ v = AWSConfig[aws_profile][prop.to_s]
131
+ v unless v.blank?
133
132
  end
134
- memoize :aws_configure_get
133
+ memoize :aws_config
135
134
 
136
135
  def aws_profile
137
136
  ENV['AWS_PROFILE'] || 'default'
@@ -1,3 +1,3 @@
1
1
  module AwsMfaSecure
2
- VERSION = "0.3.5"
2
+ VERSION = "0.3.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-mfa-secure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-10 00:00:00.000000000 Z
11
+ date: 2019-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aws_config
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: memoist
43
57
  requirement: !ruby/object:Gem::Requirement