prx-ruby-aws-creds 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/prx-ruby-aws-creds.rb +33 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cce824dd97bacb1eccc3f4c4613b45293c19b7d4bc5daa459dc7b92ab079c589
|
4
|
+
data.tar.gz: 1a5926a825795f2139f7359a333e5ecbb7a98bad19b3c3a7cb93f074fe679c99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffabc5525944d2bbe2fe016414942327a158802fec52d06cc721423b1d811e2decd622e58b5a967cac02480f1c6806bbb167a17587bff849dc986af59cbff66b
|
7
|
+
data.tar.gz: 497b5a132f0aef4249991a9fd1b5d11ee848c7de766bdeec8712c70aa8c78ba175fa97ebf53a0d735deb4a568aa279603d1732d308d8e001f3df2e1fa5e38005
|
data/lib/prx-ruby-aws-creds.rb
CHANGED
@@ -11,6 +11,27 @@ require "aws-sdk-sso"
|
|
11
11
|
CACHE_DIRECTORY = "#{Dir.home}/.aws/ruby/cache"
|
12
12
|
AWS_CONFIG_FILE = ENV["AWS_CONFIG_FILE"] || "#{Dir.home}/.aws/config"
|
13
13
|
|
14
|
+
# Normally IniFile tries to be clever about detecting number values in the file
|
15
|
+
# and casting them to Integers and Floats. This breaks on a value like
|
16
|
+
# 048723829744, becuase Integer() tries to treat that as an octal, but fails
|
17
|
+
# since it includes 8s and 9s, but Float(048723829744) treats it like a decimal
|
18
|
+
# and returns 48723829744.0. Even if Integer() didn't fail it would drop the
|
19
|
+
# leading zero. We need to just treat these values as strings, so this gets
|
20
|
+
# rid of the fancy typecasting.
|
21
|
+
class IniFile
|
22
|
+
class Parser
|
23
|
+
def typecast(value)
|
24
|
+
case value
|
25
|
+
when %r{\Atrue\z}i then true
|
26
|
+
when %r{\Afalse\z}i then false
|
27
|
+
when %r{\A\s*\z}i then nil
|
28
|
+
else
|
29
|
+
unescape_value(value)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
14
35
|
class PrxRubyAwsCreds
|
15
36
|
class << self
|
16
37
|
# The cache key is based on the parameters used to request temporary
|
@@ -59,11 +80,20 @@ class PrxRubyAwsCreds
|
|
59
80
|
aws_config_file = IniFile.load(AWS_CONFIG_FILE)
|
60
81
|
aws_config_file_section = aws_config_file["profile #{profile_name}"]
|
61
82
|
|
83
|
+
if aws_config_file["sso_session"]
|
84
|
+
sso_session_name = aws_config_file["sso_session"]
|
85
|
+
sso_session_section = aws_config_file["sso-session #{sso_session_name}"]
|
86
|
+
|
87
|
+
sso_start_url = sso_session_section["sso_start_url"]
|
88
|
+
else
|
89
|
+
sso_start_url = aws_config_file_section["sso_start_url"]
|
90
|
+
end
|
91
|
+
|
62
92
|
# The selected profile does not use SSO
|
63
|
-
return if !
|
93
|
+
return if !sso_start_url
|
64
94
|
|
65
95
|
# Get the SSO start URL for the selected profile
|
66
|
-
profile_start_url =
|
96
|
+
profile_start_url = sso_start_url
|
67
97
|
|
68
98
|
sso_access_token = sso_get_cached_access_token(profile_start_url)
|
69
99
|
|
@@ -123,7 +153,7 @@ class PrxRubyAwsCreds
|
|
123
153
|
aws_config_file = IniFile.load(AWS_CONFIG_FILE)
|
124
154
|
aws_config_file_section = aws_config_file["profile #{profile_name}"]
|
125
155
|
|
126
|
-
if aws_config_file_section["sso_role_name"]
|
156
|
+
if aws_config_file_section["sso_role_name"] || aws_config_file_section["sso_session"]
|
127
157
|
# For SSO profiles, call GetRoleCredentials with a role, account, and
|
128
158
|
# access token to get back a set of temporary credentials.
|
129
159
|
# https://docs.aws.amazon.com/singlesignon/latest/PortalAPIReference/API_GetRoleCredentials.html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prx-ruby-aws-creds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Kalafarski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inifile
|