mydrive-aws-mfa 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/aws_mfa.rb +8 -1
- data/lib/aws_mfa/credentials_loader.rb +12 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c272882302abaecec8f71659b7ce8cc73b447cc0a8439aa44ef347056d37a679
|
4
|
+
data.tar.gz: bdb70dc1ab732d04b380d3f4cd22df09f40c219a71b9ecefb780f01d53faf054
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6f5cce0cab0f4d803e07eb4014e700140ac289a8589b46f8bb122de636062f85a24de8487a1c162382e197133d8840428d8895b05d7daacc4810389c9255797
|
7
|
+
data.tar.gz: ca27d8f5078a4bb36fd628a513b79faaee617d96964bb0cd38401cfdc328e8b7626b860b582dadd142ec77d68ee0dbb9b27903edc1477f30dac5ee411560f72c
|
data/lib/aws_mfa.rb
CHANGED
@@ -59,10 +59,17 @@ class AwsMfa
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def load_credentials(profile_config)
|
62
|
-
CredentialsLoader.new(
|
62
|
+
CredentialsLoader.new(
|
63
|
+
mydrive_credentials_cache_dir,
|
64
|
+
expiration_buffer_minutes: expiration_buffer_minutes
|
65
|
+
).load_credentials(profile_config)
|
63
66
|
end
|
64
67
|
|
65
68
|
def execute_output(execution_output, credentials)
|
66
69
|
CredentialsOutputExecutor.new.execute_output(execution_output, credentials)
|
67
70
|
end
|
71
|
+
|
72
|
+
def expiration_buffer_minutes
|
73
|
+
ENV.fetch("MYDRIVE_MFA_TOKEN_EXPIRATION_BUFFER", 0).to_i
|
74
|
+
end
|
68
75
|
end
|
@@ -1,19 +1,20 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
1
|
+
require "io/console"
|
2
|
+
require "json"
|
3
|
+
require "time"
|
4
|
+
require_relative "errors"
|
5
|
+
require_relative "shell_command"
|
4
6
|
|
5
7
|
class AwsMfa
|
6
8
|
class CredentialsLoader
|
7
|
-
|
8
|
-
|
9
|
-
def initialize(mydrive_credentials_cache_dir)
|
9
|
+
def initialize(mydrive_credentials_cache_dir, expiration_buffer_minutes: 0)
|
10
10
|
@mydrive_credentials_cache_dir = mydrive_credentials_cache_dir
|
11
|
+
@expiration_buffer_seconds = expiration_buffer_minutes * 60
|
11
12
|
end
|
12
13
|
|
13
14
|
def load_credentials(profile_config)
|
14
15
|
credentials_file = File.join(mydrive_credentials_cache_dir, build_credentials_file_name(profile_config))
|
15
16
|
|
16
|
-
if File.readable?(credentials_file) &&
|
17
|
+
if File.readable?(credentials_file) && !token_expired?(credentials_file)
|
17
18
|
credentials = File.read(credentials_file)
|
18
19
|
else
|
19
20
|
credentials = load_credentials_from_aws(profile_config)
|
@@ -32,9 +33,10 @@ class AwsMfa
|
|
32
33
|
"#{source_profile}_#{profile_config.profile}_mfa_credentials"
|
33
34
|
end
|
34
35
|
|
35
|
-
def
|
36
|
-
|
37
|
-
Time.
|
36
|
+
def token_expired?(credentials_file)
|
37
|
+
credentials_file_content = JSON.parse(File.read(credentials_file))
|
38
|
+
expiration_time = Time.parse(credentials_file_content["Credentials"]["Expiration"])
|
39
|
+
Time.now.to_i + @expiration_buffer_seconds >= expiration_time.to_i
|
38
40
|
end
|
39
41
|
|
40
42
|
def load_credentials_from_aws(profile_config)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mydrive-aws-mfa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MyDrive Solutions Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
requirements:
|
92
92
|
- aws-cli
|
93
93
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.6
|
94
|
+
rubygems_version: 2.7.6
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: Run AWS commands with MFA (MyDrive fork)
|