prx-ruby-aws-creds 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/prx-ruby-aws-creds.rb +16 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e03288063d2999775ce03029bcbf2e3be1ff12095d90812dd22127058b1c7b2
4
- data.tar.gz: d919adc2def0ebfe1469d3d1a58bb8d7b4fdb4227969a8cc03bd4d2f2e3b20dc
3
+ metadata.gz: cce824dd97bacb1eccc3f4c4613b45293c19b7d4bc5daa459dc7b92ab079c589
4
+ data.tar.gz: 1a5926a825795f2139f7359a333e5ecbb7a98bad19b3c3a7cb93f074fe679c99
5
5
  SHA512:
6
- metadata.gz: abe3afa00b828ad17696254c05ba83ca446de9bb2679fd5aa57544b31fd17705f3b190688b4ee3ef46302b5d3f1e4617343cd4c1b5daf13c34cd56784bf63335
7
- data.tar.gz: 4c173dbbfaeef9dc4e240418f327325335a8130000c425aef3bd261f7bb9e71a892f5af6661210b57b7ac8548a0a7e83295c2dfc3548ce92ecb37e00a4d98748
6
+ metadata.gz: ffabc5525944d2bbe2fe016414942327a158802fec52d06cc721423b1d811e2decd622e58b5a967cac02480f1c6806bbb167a17587bff849dc986af59cbff66b
7
+ data.tar.gz: 497b5a132f0aef4249991a9fd1b5d11ee848c7de766bdeec8712c70aa8c78ba175fa97ebf53a0d735deb4a568aa279603d1732d308d8e001f3df2e1fa5e38005
@@ -20,11 +20,11 @@ AWS_CONFIG_FILE = ENV["AWS_CONFIG_FILE"] || "#{Dir.home}/.aws/config"
20
20
  # rid of the fancy typecasting.
21
21
  class IniFile
22
22
  class Parser
23
- def typecast( value )
23
+ def typecast(value)
24
24
  case value
25
- when %r/\Atrue\z/i; true
26
- when %r/\Afalse\z/i; false
27
- when %r/\A\s*\z/i; nil
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
28
  else
29
29
  unescape_value(value)
30
30
  end
@@ -80,11 +80,20 @@ class PrxRubyAwsCreds
80
80
  aws_config_file = IniFile.load(AWS_CONFIG_FILE)
81
81
  aws_config_file_section = aws_config_file["profile #{profile_name}"]
82
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
+
83
92
  # The selected profile does not use SSO
84
- return if !aws_config_file_section["sso_start_url"]
93
+ return if !sso_start_url
85
94
 
86
95
  # Get the SSO start URL for the selected profile
87
- profile_start_url = aws_config_file_section["sso_start_url"]
96
+ profile_start_url = sso_start_url
88
97
 
89
98
  sso_access_token = sso_get_cached_access_token(profile_start_url)
90
99
 
@@ -144,7 +153,7 @@ class PrxRubyAwsCreds
144
153
  aws_config_file = IniFile.load(AWS_CONFIG_FILE)
145
154
  aws_config_file_section = aws_config_file["profile #{profile_name}"]
146
155
 
147
- if aws_config_file_section["sso_role_name"]
156
+ if aws_config_file_section["sso_role_name"] || aws_config_file_section["sso_session"]
148
157
  # For SSO profiles, call GetRoleCredentials with a role, account, and
149
158
  # access token to get back a set of temporary credentials.
150
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.1.6
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-09-20 00:00:00.000000000 Z
11
+ date: 2023-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inifile